Skip to content
Advertisement

Emoji converter

How can I convert this string in python3 '👀🥶' into this '%F0%9F%91%80%F0%9F%A5%B6' ? Would like to do this with any emojis

Advertisement

Answer

If percentage encoding is what you are after, urllib module in Python could help.

Ref: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote

Python 3:

text = '👀🥶'
import urllib.parse
print(urllib.parse.quote(text))

Returns

%F0%9F%91%80%F0%9F%A5%B6
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement