所以我有这个任务,我必须使用Python将数据文件转换为csv文件。这是我的代码:
with open('autorit.data') as input_file, open('autorit.csv', 'w') as output_file:
l = [elem.strip() for elem in input_file]
l = [elem.replace(";",",") for elem in list]
n = l.count("")
for i in range(n):
list[l.index("")] = "\n"
string = ",".join(l)
string.replace(",\n", "\n")
string.replace("\n,", "\n")
#print(repr(string))
print(string)
该程序似乎无法替换\ n,\ n \ n。任何人都可以看到出了什么问题吗?