程序似乎没有认识到\ n

时间:2017-10-16 23:11:32

标签: python csv

所以我有这个任务,我必须使用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。任何人都可以看到出了什么问题吗?

0 个答案:

没有答案