如何在Python中对查询字符串进行urlencode?在提交之前,我正在尝试对此字符串进行urlencode。queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];
3 回答
手掌心
TA贡献1942条经验 获得超3个赞
urlencode()
>>> import urllib>>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'}>>> urllib.urlencode(f)'eventName=myEvent&eventDescription=cool+event'
Python 3或以上
>>> urllib.parse.urlencode(f)eventName=myEvent&eventDescription=cool+event
urllib.parse.quote_plus
.
呼如林
TA贡献1798条经验 获得超3个赞
Python 2
urllib.quote_plus
:
>>> urllib.quote_plus('string_of_characters_like_these:$#@=?%^Q^$')'string_of_characters_like_these%3A%24%23%40%3D%3F%25%5EQ%5E%24'
Python 3
urllib
urllib.parse.quote_plus
parse
import urllib.parse urllib.parse.quote_plus(...)
添加回答
举报
0/150
提交
取消