如何在Python中修改文本文件

时间:2014-03-22 10:06:31

标签: python

我有问题。如何在Python中修改文本文件?

这是我的代码:

(with open "clues.txt")
y = content.readlines

1 个答案:

答案 0 :(得分:0)

以写入模式或追加模式打开它。

with open("clues.txt", "a") as f:
    f.write("your text")

通过python文档可以帮助你更多http://docs.python.org/3/tutorial/inputoutput.html