第26讲 python文件的格式化写入

2020-01-09 14:36:17 浏览数 (1)

s="xxx%d yyy%sn" % (28,'jeapedu')

file_obj.write(s)

fd=open('format.txt','w')

head='s s s n' % ('ID','Name','Record')

fd.write(head)

item1='d s .2f' % (9510442,'Jeapedu1',78.96)

fd.write(item1)

item2='d s .2f' % (9510443,'Jeapedu2',88.96)

fd.write(item2)

item3='d s .2f' % (9510444,'Jeapedu3',94.56)

fd.write(item3)

...

...

fd.close()

0 人点赞