输入一个原始字符串,例如 hello world。 输出转换后的字符串,例如 hello%20world。

新手上路,请多包涵

输入一个原始字符串, hello world。 输出转换后的字符串, hello%20world。

新手 不会呀 求大神教怎么才能这样输出。。。。。

阅读 4.4k
3 个回答

如果是对参数的dict:

from urllib import urlencode
    data = {
         'name': 'hello world'
    }
    print urlencode(data)

如果是字符串:

from urllib import quote
    quote('hello world')
from urllib import quote
quote(str)
新手上路,请多包涵

我用 a = raw_input()
a = a.replace(' ','%20')
print a

解决了 。当时放错了 print才没能做出答案来。。。谢谢各位大神 了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题