Ale*_* S. 3 python file python-3.x
我有两个文件:
文本
和
program.py
我在我的文章中插入文字
文本
使用该行的文件:
inp=input('Text by the user')
with open("text.py", "a") as myfile:
myfile.write(inp)
Run Code Online (Sandbox Code Playgroud)
如何让程序删除文本中的行,并说出:
文本2
不
text1 text2
什么时候跑两次?
在写入模式(w)中打开而不是追加模式(a).这会在写入文件之前使文件空白.
inp=input('Text by the user')
with open("text.py", "w") as myfile:
myfile.write(inp)
Run Code Online (Sandbox Code Playgroud)