84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
I'm trying to urlencode the string before submitting it.
queryString = 'eventName=' evt.fields["eventName"] '&' 'eventDescription=' evt.fields["eventDescription"];< /pre>
What you are looking for isurllib.quote_plus:
urllib.quote_plus
safe_string = urllib.quote_plus('string_of_characters_like_these:$#@=?%^Q^$') #Value: 'string_of_characters_like_these%3A%24%23%40%3D%3F%25%5EQ%5E%24'
In Python 3, theurllibpackage has been broken into smaller components. You would useurllib.parse.quote_plus(note theparsesubmodule)
urllib
urllib.parse.quote_plus
parse
import urllib.parse safe_string = urllib.parse.quote_plus(...)
You need to pass the parameters tourlencode()as a map (dict) or sequence of tuples, for example:
urlencode()
>>> import urllib >>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'} >>> urllib.urlencode(f) 'eventName=myEvent&eventDescription=cool+event'
Python 3 or higher
Usingurllib.parse.urlencode:
urllib.parse.urlencode
>>> urllib.parse.urlencode(f) eventName=myEvent&eventDescription=cool+event
Note that thisdoes notperform url encoding in the usual sense (see the output). To do this, useurllib.parse.quote_plus代码>.
urllib.parse.quote_plus代码>
Python 2
What you are looking for is
urllib.quote_plus
:Python 3
In Python 3, the
urllib
package has been broken into smaller components. You would useurllib.parse.quote_plus
(note theparse
submodule)You need to pass the parameters to
urlencode()
as a map (dict) or sequence of tuples, for example:Python 3 or higher
Using
urllib.parse.urlencode
:Note that thisdoes notperform url encoding in the usual sense (see the output). To do this, use
urllib.parse.quote_plus代码>
.