PYTHON 学习笔记 011~2

读取与写入

#不能读取中文字编码,显示乱码file = open("5566.txt", mode="r")file.write("\n很棒吧!")file.close()

http://img2.58codes.com/2024/20156136ipibn0mzJW.jpg

#第三个参数:显示中文编码file = open("5566.txt", mode="a", encoding="utf-8")file.write("\n很棒吧!")file.close()

http://img2.58codes.com/2024/20156136mQDL1t4vc7.jpg

#自动执行CLOSE关闭档案with open ("5566.txt", mode="a", encoding="utf-8") as file:    file.write("\n超级厉害的啦~~~~")

http://img2.58codes.com/2024/20156136gRwZ5Yqrzk.jpg


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章