![](/img/trans.png)
[英]Exception when trying to import python mysql connector on raspberry pi
[英]python '_mysql_connector' 'convert_to_mysql' method get exception when given string with character � in linux server
我在 linux 服務器中運行以下腳本:
import _mysql_connector
ccnx = _mysql_connector.MySQL()
ccnx.connect(user=<user_name>, database=<db_name>, password=<pass>, host=<host>)
bad_str = 'just_an_��_example'
try:
str_converted = ccnx.convert_to_mysql(*[bad_str])
print('str converted is %s', str_converted)
except Exception as e:
print('cant convert bad str %s',bad_str)
print(e)
腳本出現異常“轉換 Python 'str' 失敗” 。
我嘗試在運行腳本之前添加編碼導出:
它也沒有用。。
該問題還在macos終端中重現了該問題。
我在 mysql-connector-python 的 8.0.21 版本中遇到了同樣的錯誤。 我通過恢復到 mysql-connector-python 8.0.12 讓它工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.