In [54]: a=parse.quote('万寿寺北京', encoding='utf-8')
In [55]: a
Out[55]: '%E4%B8%87%E5%AF%BF%E5%AF%BA%E5%8C%97%E4%BA%AC'
In [56]: a.split("%")
Out[56]:
['', 'E4', 'B8', '87', 'E5', 'AF', 'BF', 'E5', 'AF', 'BA', 'E5', '8C', '97', 'E4', 'BA', 'AC']
In [57]: a
Out[57]: '%E4%B8%87%E5%AF%BF%E5%AF%BA%E5%8C%97%E4%BA%AC'
In [58]: type(a.split("%"))
Out[58]: list
In [59]: a.split("%")[1:]
Out[59]:
['E4', 'B8', '87', 'E5', 'AF', 'BF', 'E5', 'AF', 'BA', 'E5', '8C', '97', 'E4', 'BA', 'AC']
In [60]: str=''
In [61]: for i in a.split("%")[1:]:
...: i = '%25'+i
...: str = str + i
...:
In [62]: str
Out[62]: '%25E4%25B8%2587%25E5%25AF%25BF%25E5%25AF%25BA%25E5%258C%2597%25E4%25BA%25AC'
相比较之下,qunar就没那么心机