1. 程式人生 > >python實現資料庫序列化儲存帶有漢字的列表

python實現資料庫序列化儲存帶有漢字的列表

import pymysql
import json
b = ["你","好"]
b = json.dumps(b,ensure_ascii=False)

conn = pymysql.connect(host="",port=3306,user='',password='',db='',charset='utf8')
cursor = conn.cursor()
cursor.execute("insert into ceshi(name) value('%s')"%b)
conn.commit()