Pyhton 操作数据库返回中文

来源:互联网 发布:如何开发三维软件 编辑:程序博客网 时间:2024/06/10 16:10
设置charset
def GET(self):    conn = MySQLdb.connect(host='localhost', user='root', passwd='', db='test', port=3306, charset='utf8', cursorclass=MySQLdb.cursors.DictCursor)    cur = conn.cursor()    cur.execute("select * from articles")    r = cur.fetchall()    cur.close()    conn.close()    print r    return render.articles(r)
0 0
原创粉丝点击