I\'m trying to get python to give me percent encoded strings. The API I\'m interacting with (which I think is using percent encoded UTF-8), gives %c3%ae for î. However, pyth
Your file has to encode your string as utf-8 before quoting it, and the string should be unicode. Also you have to specify the appropriate file encoding for your source file in the coding section:
# -*- coding: utf-8 -*-
import urllib
s = u'î'
print urllib.quote(s.encode('utf-8'))
Gives me the output:
%C3%AE