将utf8解码为big5

2024-09-29 22:31:29 发布

您现在位置:Python中文网/ 问答频道 /正文

每一个,我尝试用python发送短信,我可以发送,但是我需要用中文发送,这是big5,我必须将utf8解码成big5,这是我的sms python代码

trydecode.py

import urllib
import urllib2


def sendsms(phonenumber,textcontent):
    textcontent.decode('utf8').encode('big5')
    url = "https://url?username=myname&password=mypassword&dstaddr="+phonenumber+"&smbody="+textcontent
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)

这个代码(python2.7)我可以用英文发短信,但中文(big5)有问题,我该怎么解决?谢谢你


Tags: 代码pyimporturlutf8urllib2urllib解码

热门问题