The Django project encountered the following error when invoking the Urllib.urlencode encoded Chinese string when accessing the restful service
v = quote_plus (str (v)) 'ascii' codec can't encode characters in Position ......
This error in WINDOWS7 development environment did not happen, in the Linux production environment occurred, compared to depressed, just after the launch of the Bug.google, in a Chinese literature (link see resources) in the URL string can not be a Unicode string, if, Must be encoded into GBK or UTF-8, in the Django environment, this is really annoying, fortunately, in time to find this information, the Chinese string adopted the encode (' Utf-8 ') method of encoding conversion:
Utfstr = Unicodestr.encode ('utf-8')
Pass that utfstr to the corresponding URL encoding function.
Reference: http://lijiang.iteye.com/blog/312247
An issue with urllib.urlencode Chinese characters in Python