How to write UTF-8 in a CSV file
问题 I am trying to create a text file in csv format out of a PyQt4 QTableWidget . I want to write the text with a UTF-8 encoding because it contains special characters. I use following code: import codecs ... myfile = codecs.open(filename, 'w','utf-8') ... f = result.table.item(i,c).text() myfile.write(f+";") It works until the cell contains a special character. I tried also with myfile = open(filename, 'w') ... f = unicode(result.table.item(i,c).text(), "utf-8") But it also stops when a special