Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过Python拆分记事本文件中的文本_Python_File_Notepad_Writing - Fatal编程技术网

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

通过Python拆分记事本文件中的文本,python,file,notepad,writing,Python,File,Notepad,Writing,这是附加到文本文件的代码,在我运行程序后,我检查了记事本文件以查看结果。我发现我输入的每个名字都是组合在一起的。如何通过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 technic

这是附加到文本文件的代码,在我运行程序后,我检查了记事本文件以查看结果。我发现我输入的每个名字都是组合在一起的。如何通过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)

使用
fi.write(str(name)+“\t”)

拆分名称是否要在新行中添加名称?然后使用fi.write(“\n”+str(name))输入什么?电流输出是多少?预期的输出是什么?输入只是一个名称,但如果我同时输入多个名称,则记事本文件中的输出只是所有名称的一个长字符串,希望名称分开。我尝试了此操作,但现在我的时间到了。如果我运行itremove,睡眠(20)似乎会丢失\t然后尝试但保留空格谢谢,对于其他有同样问题的人来说,空间位对我很有效&时间。睡眠也很有效!欢迎您,祝您愉快,如果有帮助,请不要忘记投票:)谢谢您,您也是!我确实投了赞成票,但我认为这不算,因为我的代表还不到15岁,对不起!