I have a csv file like this
Niklas Fagerstr�m http://www.vimeo.com/niklasf 5379549 5379549
Niklas Fagerstr�m http://fagerstrom.eu/en 5379549 5379549
I reading
Niklas Fagerstr�m
Niklas Fagerstr�m
This two fields so all the ? characters should be encoded but my script is not encoding
import csv
import MySQLdb
import re
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
with open('finland_5000_rows.csv', 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in spamreader:
#row[0] = row[0].encode('')
one = row[0]
print one
Output:
Niklas Fagerstr�m
Niklas Fagerstr�m
But i want output like this
Niklas Fagerström
Niklas Fagerström
What change should i make in above code to get expected result?
发生这种情况时,我要做的就是将文本从csv复制到notepad ++,然后按转换为UTF-8并保存。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.