这是附加到文本文件的代码,在我运行程序后,我检查了记事本文件以查看结果。我发现我所招的每个名字都被合并了。如何通过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)
答案 0 :(得分:0)
使用fi.write(str(name)+" \t")
分割名称。