小编use*_*653的帖子

UnicodeDecodeError:'ascii'编解码器无法解码位置0中的字节0xc3:序数不在范围内(128)

我正在使用google appengine python 2.5.

我在下面的代码中遇到unicodedecoderror,因为myuser名称具有以下值

userName     = unicode(userName).encode('utf-8') # äºï¼égãwmj is value in this variable  

userName     = unicode(userName).encode('utf-8')
strData = '{\"Sid\" :1, \"Oppid\" :%s, \"Aid\" :%s, \"EC\" :\"%s\", \"Name\" :\%s"' % (enemyID, userID, userEmpCode,userName)


   params = {'deviceToken'   : oDeviceToken,
              'message'       : strMessage,
              'CertificateId' : certificateId,
              'Data'          : strData
             }


result = urlfetch.fetch(url = url,
             payload = urllib.urlencode(params),
             method  = urlfetch.POST,
             headers = {"Authorization" : authString},
             deadline = 30
             )
Run Code Online (Sandbox Code Playgroud)

我在用户名上执行以下步骤将其编码为utf-8,以便我可以将其作为有效负载发送.

username = unicode(username).encode(utf-8)
Run Code Online (Sandbox Code Playgroud)

我相信当我打电话时会发生错误 urllib.urlencode(params)

请指导出错的地方......或者你可以..

什么应该是处理appengine python上的unicode字符串的最终策略..

我尝试了不同的解决方案阅读不同的线程..但仍然无法正常工作

python unicode google-app-engine decode

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

decode ×1

google-app-engine ×1

python ×1

unicode ×1