首页 > 代码库 > python 输出十六进制中文乱码

python 输出十六进制中文乱码

代码中红色字体为解决方案:

 1 #-*-coding:utf-8-*
 2 import csv
 3 
 4 filename=C:\Users\yaru\Desktop\Senti_Value(1).csv
 5 
 6 data=http://www.mamicode.com/[]
 7 try:
 8     with open(filename) as f:
 9         reader = csv.reader(f)
10         header = reader.next()
11         data = http://www.mamicode.com/[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()

 

python 输出十六进制中文乱码