文件的操作 文件:是最持久数据保存形式。 1.打开文件 ’file = open("1.txt"."w")‘ 2.操作文件 ’file.write("hello.itcast ")’ 3.关闭文件 ’file.close()’ 文件操作完毕文件自动关闭,否则将长期保持对文件的连接状态。 免关闭文件格式: with open(".txt","w/a/r") as file: file.write() rb 读取数据 wb 写入数据,覆盖原内容。 ab 追加数据