python - 输入一个原始字符串,例如 hello world。 输出转换后的字符串,例如 hello%20world。
迷茫
迷茫 2017-04-17 17:40:59
0
3
1296

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

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

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回覆(3)
左手右手慢动作

如果是對參數的dict:

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

如果是字串:

from urllib import quote
    quote('hello world')
Ty80

雷雷

Ty80

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

解決了 。當時放錯了 print才沒能做出答案來。 。 。謝謝各位大神 了

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!