100 Jason Smith 200 John Doe 300 Sanjay Gupta 400 Ashok Sharma
100 $5,000 200 $500 300 $3,000 400 $1,250
400 ashok sharma $1,250 100 jason smith $5,000 200 john doe $500 300 sanjay gupta $3,000
#! /usr/bin/env python
#coding=utf-8
fp01=open("bonus.txt","r")
a=[]
for line01 in fp01:
a.append(line01)
fp02=open("employee.txt","r")
fc02=sorted(fp02,key=lambda x:x.split()[1])
for line02 in fc02:
i=0
while line02.split()[0]!=a[i].split()[0]:
i+=1
print "%s %s %s %s" % (line02.split()[0],line02.split()[1],line02.split()[2],a[i].split()[1])
fp01.close()
fp02.close()
# coding gbk
#
# author: GreatGhoul
# email : greatghoul@gmail.com
# blog : http://greatghoul.javaeye.com
import sys,os,msvcrt
def join(in_filenames, out_filename):
out_file = open(out_filename, 'w+')
err_files = []
for file in in_filenames:
try:
in_file = open(file, 'r')
out_file.write(in_file.read())
out_file.write('\n\n')
in_file.close()
except IOError:
print 'error joining', file
err_files.append(file)
out_file.close()
print 'joining completed. %d file(s) missed.' % len(err_files)
print 'output file:', out_filename
if len(err_files) > 0:
print 'missed files:'
print '--------------------------------'
for file in err_files:
print file
print '--------------------------------'
if __name__ == '__main__':
print 'scanning...'
in_filenames = []
file_count = 0
for file in os.listdir(sys.path[0]):
if file.lower().endswith('[all].txt'):
os.remove(file)
elif file.lower().endswith('.txt'):
in_filenames.append(file)
file_count = file_count + 1
if len(in_filenames) > 0:
print '--------------------------------'
print '\n'.join(in_filenames)
print '--------------------------------'
print '%d part(s) in total.' % file_count
book_name = raw_input('enter the book name: ')
print 'joining...'
join(in_filenames, book_name + '[ALL].TXT')
else:
print 'nothing found.'
msvcrt.getch()
#!coding: cp936
import codecs, chardet
def fileopen(filename):
f = open(filename, 'r')
s = f.read()
if(chardet.detect(s)['encoding'] == 'UTF-16LE'):
f.close()
f = codecs.open(filename, 'r', 'utf-16-le')
data = f.read().encode('gb2312', 'ignore')
f.close()
elif(chardet.detect(s)['encoding'] == 'GB2312'):
data = s
f.close()
return data
i = 1
while i <=87:
if(i < 10):
filename = '0'+str(i)+'.txt'
else:
filename = str(i)+'.txt'
text = fileopen(filename)
file('crazy-p.txt', 'a+').write(text)
i = i+1
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有