我有一个包含特殊字符的字符串: “Mystring?”
这是我的mysql数据库编码设置:
这是我得到的错误:
Incorrect string value: '\xF0\x9F\x9A\xB0' for column 'name' at row 1
为避免错误,我也尝试替换字符序列,但未成功:
>>>string = "Mystring?"
>>>print(string.encode())
b'Mystring\xf0\x9f\x9a\xb0'
>>>print(string.encode().replace("\xf0\x9f\x9a\xb0",""))
TypeError: a bytes-like object is required, not 'str'