使用python向數據庫插入數據時,報錯:‘latin-1’ codec can’t encode characters in position 73-83: ordinal not in range(256)
使用百度翻譯看了一下錯誤信息,大概意思就是編碼錯誤,在連接數據庫時,加上編碼:
pymysql.connect(host='localhost', port=3306, user='root', passwd='root', db='python_test', charset='utf8')
加上編碼之後就可以執行成功啦: