python 輸出十六進制中文亂碼

代碼中紅色字體爲解決方案:字體

 1 #-*-coding:utf-8-*
 2 import csv
 3 
 4 filename='C:\Users\yaru\Desktop\Senti_Value(1).csv'
 5 
 6 data=[]
 7 try:
 8     with open(filename) as f:
 9         reader = csv.reader(f)
10         header = reader.next()
11         data = [row for row in reader]
12 except csv.Error as e:
13     print "Error reading CSV file at line %s: %s" % (reader.line_num,e)
14     sys.exit(-1)
15 
16 if header:
17     print ','.join(header)
18     print '============'
19 for datarow in data:
20     print ','.join(datarow)
21 f.close()
相關文章
相關標籤/搜索