今天使用MySQLdb往MySQL插入中文數據遇到一個異常:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-3: ordinal not in range(256)
解決辦法:
conn = MySQLdb.connect(host="localhost", user="root", passwd="root", db="chemical", charset="utf8")
今天使用MySQLdb往MySQL插入中文數據遇到一個異常:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-3: ordinal not in range(256)
解決辦法:
conn = MySQLdb.connect(host="localhost", user="root", passwd="root", db="chemical", charset="utf8")
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。