when writing to csv file writerow fails with UnicodeEncodeError

前端 未结 2 447
南方客
南方客 2021-01-17 12:48

I have the line:

c.writerow(new_values)

That writes a number of values to a csv file. Normally it is working fine but sometimes it throws a

2条回答
  •  执笔经年
    2021-01-17 13:05

    Ok, I solved it by myself:

    I just had to add ", encoding='utf-8'" to my csv.writer line:

    c = csv.writer(open("Myfile.csv", 'w',  newline='', encoding='utf-8'))
    

提交回复
热议问题