📜  python如何对齐写入文件的文本 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:39.087000             🧑  作者: Mango

代码示例1
file = open(file, "a") 
table_data = [
    ['a', 'b', 'c'],
    ['aaaaaaaaaa', 'b', 'c'], 
    ['a', 'bbbbbbbbbb', 'c']
]
for row in table_data:
    file.write("{: >20} {: >20} {: >20}".format(*row))