Cc L Cc L - 1 year ago 152
Python Question

decode utf8 to big5

every one,I am trying to send sms by python, I can send it,but I need to send in Chinese, which is big5,I have to decode utf8 to big5,here is my sms python code

import urllib
import urllib2

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

this code(python2.7) I can send sms in English but in Chinese (big5) got problem,how can I fix it? thank you

Answer Source

I think you forgot to save it to change the variable.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download