Quotes a string for use in a URL. >>> urlquote('://?f=1&j=1') '%3A//%3Ff%3D1%26j%3D1' >>> urlquote(None) '' >>> urlquote(u'\u203d') '%E2%80%BD'
(val)
| 174 | |
| 175 | |
| 176 | def urlquote(val): |
| 177 | """ |
| 178 | Quotes a string for use in a URL. |
| 179 | |
| 180 | >>> urlquote('://?f=1&j=1') |
| 181 | '%3A//%3Ff%3D1%26j%3D1' |
| 182 | >>> urlquote(None) |
| 183 | '' |
| 184 | >>> urlquote(u'\u203d') |
| 185 | '%E2%80%BD' |
| 186 | """ |
| 187 | if val is None: |
| 188 | return "" |
| 189 | |
| 190 | val = str(val).encode("utf-8") |
| 191 | return quote(val) |
| 192 | |
| 193 | |
| 194 | def httpdate(date_obj): |