Discuss / Python / 添加文字后打印

添加文字后打印

Topic source
fpath = r'd:\1.txt'

with open(fpath, 'a',encoding='utf-8') as f:
    s=f.write('添加文字')
with open(fpath, 'r',encoding='utf-8') as f:
    print(f.read())

添加文字后打印,感觉写的有点臃肿啊。


  • 1

Reply