通过Python拆分记事本文件中的文本

2024-04-23 06:57:55 发布

您现在位置:Python中文网/ 问答频道 /正文

这是附加到文本文件的代码,在我运行程序之后,我检查了记事本文件以查看结果。我发现我输入的每个名字都是合二为一的。如何通过Python将记事本文件中的名称拆分?你知道吗

import time
print("Please contact a technician - what is your name?")
name = input(">")
print("I will allocate your name as a case number for a"\
      " future technician, so that they can assist you.")
fi = open("casenumbers.txt", "a")
fi.write(str(name))
fi.close()
print("The name you should contact us with is",name,"")
time.sleep(20)

Tags: 文件代码name程序youyourtimeis