Simplify and speed-up quote_plus().
This commit is contained in:
parent
199d2f7997
commit
957b126649
@ -1115,12 +1115,9 @@ def quote(s, safe = '/'):
|
|||||||
def quote_plus(s, safe = ''):
|
def quote_plus(s, safe = ''):
|
||||||
"""Quote the query fragment of a URL; replacing ' ' with '+'"""
|
"""Quote the query fragment of a URL; replacing ' ' with '+'"""
|
||||||
if ' ' in s:
|
if ' ' in s:
|
||||||
l = s.split(' ')
|
s = s.replace(' ', '+')
|
||||||
for i in range(len(l)):
|
safe += '+'
|
||||||
l[i] = quote(l[i], safe)
|
return quote(s, safe)
|
||||||
return '+'.join(l)
|
|
||||||
else:
|
|
||||||
return quote(s, safe)
|
|
||||||
|
|
||||||
def urlencode(query,doseq=0):
|
def urlencode(query,doseq=0):
|
||||||
"""Encode a sequence of two-element tuples or dictionary into a URL query string.
|
"""Encode a sequence of two-element tuples or dictionary into a URL query string.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user