python open 追加

今天操做失误,致使home目录没空间了,结果跑了3天的程序断了,还好代码能够从新运行。html

读写的文件使用追加方式:spa

# a
# 打开一个文件用于追加(只写),写入内容为str
# 若是该文件已存在,文件指针将会放在文件的结尾,新的内容将会被写入到已有内容以后
# 若是该文件不存在,建立新文件进行写入
# file = open('test.txt', 'a')
# 建立一个空文件
# file = open('text.txt', 'a')
# file.write('aaa')
# file.close()
# file = open('text.txt')
# print(file.read())
# file.close()

参考:https://www.cnblogs.com/zacharyVic/p/8940143.html指针

相关文章
相关标签/搜索