我不知道这些短语中存在的编码是什么(我也想要回答这个问题)。主要是,我想改变我的短语。
例如:
Hello World!成为 Hello%20World!%0A
Olámbndo!变为 Ol%C3%A1%20mundo!%0A%0A
我想要一个python解决方案。
如果我有
>>>
Phrase ='Olámundo!'
如何将其更改为
>>>
FinalPhrase'01%C3%A1%20mundo!%0A%0A'
使用Python?
Google会在您的翻译网站中使用它,例如:
请参阅:
http://translate.google.com.br/#en|pt|Hello%20World!%0A%0A
http://translate.google.com.br/#pt|en|Ol%C3%A1%20mundo!%0A
我需要在Web应用程序中使用此功能,并使用网址连接到使用此类网址的某些网站。
答案 0 :(得分:3)
>>> import urllib2
>>> urllib2.quote
<function quote at 0x104a10848>
>>> urllib2.quote("ü")
'%C3%BC'
>>> urllib2.quote('Olá mundo!')
'Ol%C3%A1%20mundo%21'