Python使用pymysql库读取latin1编码数据的中文乱码的问题解决!

鬼谷子叔叔 - 2025-02-11 10:33

# test cn words
cursor.execute("select hex(agent_name) as agent_name from tb_agent order by 1 desc limit 100")
all = cursor.fetchall()
for item in all:
    print(codecs.decode(item["agent_name"], "hex").decode("gbk"))
exit()