[root@localhost test]# cat 1.py 
fd = open('format.txt','w')
head = "%10s%10s%10s\n"%('id','name','record')
item1 = "%10s%10s%10s\n"%('001','evilxr','98')
item2 = "%10s%10s%10s\n"%('002','Python','88')
fd.write(head)
fd.write(item1)
fd.write(item2)
fd.close()

 

[root@localhost test]# cat format.txt 
        id      name    record
       001    evilxr        98
       002    Python        88
[root@localhost test]# 

 

相关文章:

  • 2021-06-12
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2021-11-02
  • 2021-12-06
  • 2021-11-23
猜你喜欢
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-09-17
相关资源
相似解决方案