2005年08月19日 星期五 14:10
Skipped content of type multipart/alternative-------------- next part -------------- import os,sys,string def arui_main(dirs,fileN,fileS): linesN=[] linesS='' dirlist=os.listdir(dirs) dirlist.sort() for filename in dirlist: filepath=dirs+'\\'+filename fsock=open(filepath) lines=fsock.readlines() if lines[0][34].isdigit(): temp_num=lines[0][33:35] else: temp_num=lines[0][33] linesN.append(temp_num) linesS+=lines[1][2:-3]+'\n' fsock.close() lines=[] #m_lines=[] #m_lines[0][0]='No.' #m_lines[0][1]='width' #m_lines[0][2]='width * 2' #m_lines[0][3]='hex' #m_lines[0][4]='Sum' m_lines='width \t width*2 \t hex \t Sum\n' m_sum=0 for i in range(len(linesN)): m_sum+=int(linesN[i]) m_lines=m_lines+str(int(linesN[i])/2)+'\t'+linesN[i]+'\t'+str(hex(int(linesN[i])))+'\t'+hex(m_sum)+'\n' lines_temp=string.split(linesS) for j in range(len(lines_temp)): lines_temp[j]=lines_temp[j]+', //'+dirlist[j]+'\n' fsockN=open(fileN,'w') fsockN.writelines(m_lines) fsockS=open(fileS,'w') fsockS.writelines(lines_temp) if __name__ == "__main__": if len(sys.argv)<4: print "have no enough parameter\n" print "Usage: command object_dir offtable.txt arraylist.txt" sys.exit(0) else: arui_main(sys.argv[1],sys.argv[2],sys.argv[3]) print 'all done ! \n ^_^\n' print 'offtable file is ',sys.argv[2],' and array list file is ',sys.argv[3],'\n' -------------- next part -------------- A non-text attachment was scrubbed... Name: lists.rar Type: application/octet-stream Size: 13740 bytes Desc: 1092779798-lists.rar Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20050819/52aee939/lists-0001.obj
Zeuux © 2025
京ICP备05028076号