用python向MySQL中插入中文數據出錯,原代碼片斷:python
運行提示:sql
UnicodeEncodeError: 'latin-1' codec can't encode character u'\u674e' in position 0: ordinal not in range(256)
解決方案:code
db = MySQLdb.connect("localhost","root","123","TESTDB",use_unicode=1, charset='utf8')