今天使用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") 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-01-24
  • 2021-06-29
相关资源
相似解决方案