读取与写入
#不能读取中文字编码,显示乱码file = open("5566.txt", mode="r")file.write("\n很棒吧!")file.close()
#第三个参数:显示中文编码file = open("5566.txt", mode="a", encoding="utf-8")file.write("\n很棒吧!")file.close()
#自动执行CLOSE关闭档案with open ("5566.txt", mode="a", encoding="utf-8") as file: file.write("\n超级厉害的啦~~~~")