python mysql utf8mb4

G8bao7發表於2016-12-29
conn = MySQLdb.connect(host=ip, port=port, user=user, passwd=passwd, db=db, charset="utf8", connect_timeout=1)
cur = conn.cursor()
#將這3個 character_set_client, character_set_connection, and character_set_results 都設為 utf8mb4
cur.execute("set names utf8mb4")

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26250550/viewspace-2131611/,如需轉載,請註明出處,否則將追究法律責任。

相關文章