问题:'ascii' codec can't encode characters in position 0-25: ordinal not in range(128)

解决:

import sys

reload(sys)
sys.setdefaultencoding()



报错:{"errcode":41011,"errmsg":"missing agentid"}

解决:

微信服务器只接受string字符格式。将发送内容从unicode转换成string格式.encode('utf8')

在python中直接对一个unicode字符print你是看不到异常的,它的输出和string的字符输出是一样,只能通过type来区分。而且在python的类型转换时,会将unicode编码转换成ascii码,变成形如:u'\u54c8\u54c8'的东西。。



报错:{"errcode":44003,"errmsg":"empty news data"}

解决:核对微信官方消息格式,少写news段。