蓝绝

博客园 首页 新随笔 联系 订阅 管理

2022年10月3日 #

摘要: file=open('a.txt','w') #a.txt 如果没有就会创建新的文件 file.write('python') #文件写入python file.close() file=open('a.txt','a') # a 文件追加内容 file.write('python1') file. 阅读全文
posted @ 2022-10-03 22:05 蓝绝 阅读(71) 评论(0) 推荐(0)

摘要: #pycharm 新建文件或其他文件默认为 UTF-8 格式,如果新建文件中有中文,就会读取失败,可把文件另存为其他格式(gbk) file=open('a.txt','r') #打开读取文件#需手动新建a.txt.文件 print(file.readline()) #输出读取文件内容 file.c 阅读全文
posted @ 2022-10-03 21:03 蓝绝 阅读(40) 评论(0) 推荐(0)

摘要: 阅读全文
posted @ 2022-10-03 20:17 蓝绝 阅读(29) 评论(0) 推荐(0)