【发布时间】:2021-04-30 00:43:41
【问题描述】:
图片中的代码是否正确? 执行时它不会打开任何东西。 代码应该复制第一个txt文件的内容并粘贴到第二个txt文件中,用“/t”分隔还是我错了?
infile = mainpath + "/" + "customer-churn-model/Customer Churn Model.txt"
outfile = mainpath + "/" + "customer-churn-model/Tab Customer Churn Model.txt"
with open(infile,"r") as infile1:
with open(outfile,"w") as outfile1:
for line in infile1:
fields = line.strip().split(",")
outfile1.write("/t".join(fields))
【问题讨论】:
标签: python text-files txt