将utf8解码为big5
decode utf8 to big5
每个人,我正在尝试通过 python 发送短信,我可以发送,但我需要发送中文,这是 big5,我必须将 utf8 解码为 big5,这是我的短信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) 有问题,我该如何解决?谢谢
我想你忘了保存它来更改变量。
textcontent = textcontent.decode('utf8').encode('big5')
每个人,我正在尝试通过 python 发送短信,我可以发送,但我需要发送中文,这是 big5,我必须将 utf8 解码为 big5,这是我的短信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) 有问题,我该如何解决?谢谢
我想你忘了保存它来更改变量。
textcontent = textcontent.decode('utf8').encode('big5')