RanRag
RanRag

Reputation: 49597

urllib.quote DOT character( . ) in python

I am trying to use urllib.quote on DOT character (.) in python but am not getting my desired outptut.

>>> urllib.quote(".")
'.'
>>> urllib.quote_plus(".")
'.'

but when I unquote %2E using urllib.unquote I get

>>> urllib.unquote("%2E")
'.'

So, my question is why am I not able to get %2E as my output when I use quote or quote_plus on .

Upvotes: 1

Views: 3566

Answers (2)

dilip kumbham
dilip kumbham

Reputation: 709

The link for Reference is http://docs.python.org/library/urllib.html '_.-' doesn't require a quote.

Upvotes: 2

ThiefMaster
ThiefMaster

Reputation: 318778

Dots do not need to be escaped. However, unquote converts all %xx characters since it is perfectly valid to encode any character, no matter if necessary or not.

Upvotes: 3

Related Questions