urllib.urlencode doesn't like unicode values: how about this workaround?

前端 未结 8 758
予麋鹿
予麋鹿 2020-12-12 18:59

If I have an object like:

d = {\'a\':1, \'en\': \'hello\'}

...then I can pass it to urllib.urlencode, no problem:



        
8条回答
  •  没有蜡笔的小新
    2020-12-12 19:34

    this one line working fine in my case -->

    urllib.quote(unicode_string.encode('utf-8'))
    

    thanks @IanCleland and @PavelVlasov

提交回复
热议问题