Python3 文件读写(持续更新)
生活随笔
收集整理的這篇文章主要介紹了
Python3 文件读写(持续更新)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Python3 文件讀寫(持續更新)
創建文件+關閉文件+讀取+寫入
f = open('C:\\project\\python\\test1.txt', 'w', encoding='utf-8') f.write("床前明月光\n疑是地上霜\n舉頭望明月\n低頭思故鄉") f.close() f = open('C:\\project\\python\\test1.txt', 'r', encoding='utf-8') F = open('C:\\project\\python\\test2.txt', 'w', encoding='utf-8') for i in f:print(i)F.write(i) F.close()總結
以上是生活随笔為你收集整理的Python3 文件读写(持续更新)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pat甲级 1002 A+B for P
- 下一篇: python 查看网络模型