Kaydet (Commit) 957b1266 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Simplify and speed-up quote_plus().

üst 199d2f79
......@@ -1115,12 +1115,9 @@ def quote(s, safe = '/'):
def quote_plus(s, safe = ''):
"""Quote the query fragment of a URL; replacing ' ' with '+'"""
if ' ' in s:
l = s.split(' ')
for i in range(len(l)):
l[i] = quote(l[i], safe)
return '+'.join(l)
else:
return quote(s, safe)
s = s.replace(' ', '+')
safe += '+'
return quote(s, safe)
def urlencode(query,doseq=0):
"""Encode a sequence of two-element tuples or dictionary into a URL query string.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment