+7

How to add emoji in Python code

10/22/2019 2:37:50 PM

RAYAN(Ninja)

15 Answers

New Answer

+11

hi, in regular IDE it should not be a problem to insert emojis by keyboard or copy paste most characters. In playground, you need to put some code on top of the file to avoid error messages during execution: import sys import codecs sys.stdout = codecs.getwriter('utf_16')(sys.stdout.buffer, 'strict') Individual chars can also be placed like this: print(u"\u03A9") to know which character has which code, you can use a unicode app, most of them are free of cost.

+5

from sys import stdout stdout.reconfigure(encoding="utf-16") it will work. after you can just print directly like: print('🎊')

+5

Also there's a trick if the emoji's name is known https://code.sololearn.com/cxdmms3ZND53/?ref=app

+4

There is module : emoji Install it by: pip install emoji To start using it in program: from emoji import emojize print(emojize(':thumbs_up:')) Here, in sololearn will not work tho. If you want to show like those here: USE: from sys... encode utf-16... i forgot the code actually need to see.

+4

ninkelea python's default encoding is utf-8, before you could use emoji etc. in a python file, then you need to reconfigure it. __import__("sys").stdout.reconfigure(encoding="utf-16")

+3

★«D.Connect_Zone» thanks

+3

You can use in a large scale too But, you have to copy-paste the emoji to the code, as the keyboard doesn't support emoji in code playground https://code.sololearn.com/cK0top56CXgL/?ref=app

+3

I hope this helps https://code.sololearn.com/c7e8qIKNaM4V/?ref=app

+2

Check this code https://code.sololearn.com/cH0lSgaEq8YR/?ref=app

+2

Mirielle🐶 [Inactive] thank you

+1

★«D.Connect_Zone» can I import it in SL?

+1

Nope , not available.

+1

print ( ;) )

0

What does the stdout module do exactly? (just because I want to understand properly)

0

Mirielle🐶 [Inactive] Thanks🐱