最终,它起作用了!感谢: Gord Thompson 和 Prikkeldraad 。多谢你们 !
# -*- coding: utf-8 -*-import csvimport MySQLdbfrom UnipreSupportForCsv import UnipreWriterimport sysreload(sys) sys.setdefaultencoding('utf8')#sys.setdefaultencoding('Cp1252')conn = MySQLdb.Connection(db='testdb', host='localhost', user='testuser', passwd='testpasswd', use_unipre=0,charset='utf8')crsr = conn.cursor()crsr.execute("SELECt * FROM rfid")with open(r'test.csv', 'wb') as csvfile: uw = UnipreWriter( csvfile, delimiter=',',quotechar='"', quoting=csv.QUOTE_MINIMAL) for row in crsr.fetchall(): uw.writerow([unipre(col) for col in row])
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)