4

I want to convert Python string to URL syntax.

For example

>>> u'한글'.encode('utf-8')
'\xed\x95\x9c\xea\xb8\x80' to '%ed%95%9c%ea%b8%80'

1 Answer 1

10
>>> import urllib2
>>> urllib2.quote('한글')
'%ED%95%9C%EA%B8%80'
Sign up to request clarification or add additional context in comments.

1 Comment

This depends on the terminal or source file being UTF-8, of course. The ‘safe’ spelling would be urllib.quote(u'\ud55c\uae00'.encode('utf-8')).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.