encoding - Python: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 0: ordinal not in range(128) -> Excel -


i trying wrap head around while , have not yet seen solution not confuse me.

i got script in python should write array words (german names) excel file.

cell = [name_1, name_2, name_3]     import csv  fl = open('company_data.csv', 'w')   writer = csv.writer(fl)  writer.writerow(['name_1', 'name_2', 'name_3'])   values in cell:      writer.writerow(values)   fl.close()  

the error comes ...,line 135, in writer.writerow(values) unicodeencodeerror: 'ascii' codec can't encode character u'\xfc' in position 0: ordinal not in range(128) [finished in 1.2s exit code 1]

the names include german characters ü,ä,ö etc.

how fix this?

i think have open file , specify want write unicode. aussming want utf-8:

import codecs fl = codecs.open("company_data.csv", "w", "utf-8") 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -