s="xxx%d yyy%s\n" % (28,'jeapedu')
file_obj.write(s)
fd=open('format.txt','w')
head='%10s %10s %10s \n' % ('ID','Name','Record')
fd.write(head)
item1='%10d %10s %10.2f' % (9510442,'Jeapedu1',78.96)
fd.write(item1)
item2='%10d %10s %10.2f' % (9510443,'Jeapedu2',88.96)
fd.write(item2)
item3='%10d %10s %10.2f' % (9510444,'Jeapedu3',94.56)
fd.write(item3)
...
...
fd.close()
本文转自Tenderrain 51CTO博客,原文链接:http://blog.51cto.com/tenderrain/1614168,如需转载请自行联系原作者