今天操作失误,导致home目录没空间了,结果跑了3天的程序断了,还好代码可以重新运行。

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

# 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

相关文章:

  • 2022-12-23
  • 2021-06-11
  • 2022-01-24
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
  • 2021-08-24
猜你喜欢
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2021-12-03
  • 2022-01-27
  • 2022-02-18
相关资源
相似解决方案