public_name= json.loads(json_final_data)['list'][i]['name']
print type(public_name)
public_name=public_name.encode('utf-8')
print type(public_name)
{u'category': 709, u'status': 1, u'name': u'TripAdvisor\u732b\u9014\u9e70\u4ff1\u4e50\u90e8', u'weixinID': u'gh_adaee5ccb849', u'appID': u'wx2041561f340e2ece', u'openName': u'TripAdvisor\u732b\u9014\u9e70\u4ff1\u4e50\u90e8', u'status_update_time': 0, u'auth_time': u'1519381802', u'wxname': u'gh_adaee5ccb849', u'category_name': u'\u65c5\u6e38-\u65c5\u6e38OTA\u7efc\u5408\u5e73\u53f0'}
<type 'unicode'>
<type 'str'>
gh_adaee5ccb849
Traceback (most recent call last):
File "Wechat_Mp.py", line 51, in <module>
c.client_list()
File "/home/stephen/PycharmProjects/Wechat_MP/customer.py", line 67, in client_list
self.cursor.execute(sql)
File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 165, in execute
result = self._query(query)
File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 321, in _query
conn.query(q)
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1061, in _read_query_result
result.read()
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1349, in read
first_packet = self.connection._read_packet()
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1018, in _read_packet
packet.check_error()
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 384, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, u"Unknown column
'TripAdvisoru732bu9014u9e70u4ff1u4e50u90e8' in 'field list'")
你执行的sql语句有问题。打印下你生成的sql语句就知道为什么了。