Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将utf8解码为big5_Python_Utf 8_Big5 - Fatal编程技术网

Python 将utf8解码为big5

Python 将utf8解码为big5,python,utf-8,big5,Python,Utf 8,Big5,每个人,我正在尝试用python发送短信,我可以发送,但我需要用中文发送,这是big5,我必须将utf8解码为big5,这是我的短信python代码 trydecode.py 这个代码(python2.7)我可以用英文发送短信,但中文(big5)有问题,我如何解决?谢谢我想您忘记保存它来更改变量了 textcontent=textcontent.decode('utf8').encode('big5')我想您忘记保存它来更改变量了 textcontent=textcontent.decode('

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

trydecode.py


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

我想您忘记保存它来更改变量了


textcontent=textcontent.decode('utf8').encode('big5')

我想您忘记保存它来更改变量了


textcontent=textcontent.decode('utf8')。encode('big5')

中文不是big5;UTF-8也能很好地表达中文。重要的是你发送数据到的端点需要什么编码;UTF-8也能很好地表达中文。重要的是你发送数据到的端点需要什么编码。我会,stackoverflow在10分钟后说我会,stackoverflow在10分钟后说
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)