写入txt
df = [[序号,内容],[1,'abc'],[2,'efg']]
with open(r'test.txt', 'w', encoding='utf-8')as f:
for i in tables:
print(i)
f.write(','.join(i))
f.write('\n')
f.close()
写入样式:
读取txt
with open(r'test.txt', 'r')as f:
data = f.read().split('\n')
f.close()
print(data)
运行结果