使用pymysql unicode

2024-10-06 14:29:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用pymysql进行数据库连接。 但当我调用过程并得到unicode值结果时,它会中断。你知道吗

conn = pymysql.connect(host=host, user=user, password=pw, db=db, charset='utf8mb4', use_unicode=True)
cs = conn.cursor()
cs.callproc('procedure_name', (arg, ))
for row in cs:
    str=row[0]

str中的unicode数据,它查看“\ub2e4\uc0b0\uc9c0\uc564\uc9c0-\uc5f0\uad6c” 意思是“다산지앤지-연구소”。 我正在尝试编码和解码,它只是更像字节样式。 我怎样才能解决这个问题?你知道吗


Tags: 数据库hostdb过程connectunicodepasswordcs