Simple ascii url encoding with python

后端 未结 6 1270
不思量自难忘°
不思量自难忘° 2021-01-16 12:23

look at that:

import urllib
print urllib.urlencode(dict(bla=\'Ã\'))

the output is

bla=%C3%BC

what I want

6条回答
  •  攒了一身酷
    2021-01-16 12:49

    If your input is actually UTF-8 and you want iso-8859-1 as output (which is not ASCII) what you need is:

    'ñ'.decode('utf-8').encode('iso-8859-1')
    

提交回复
热议问题