这应该很简单:
with open('somefile.txt', 'a') as the_file: the_file.write('Hellon')从文档:
os.linesep写入以文本模式打开的文件时(默认),请勿用作行终止符;在所有平台上都使用一个’ n’代替。
一些有用的读物:
- with声明
- open()
- ‘a’用于追加或使用
- ‘w’截断书写
- os(特别是os.linesep)

这应该很简单:
with open('somefile.txt', 'a') as the_file: the_file.write('Hellon')从文档:
os.linesep写入以文本模式打开的文件时(默认),请勿用作行终止符;在所有平台上都使用一个’ n’代替。
一些有用的读物: