Adding Emojis to your Python script

If you are writing a python script, and want to add some emoji to add prosperity and happiness 🥰 to the teams when running this import script, you may be shocked by the error message that can break your heart 😞💔

SyntaxError: Non-ASCII character '\xf0' in file start.py

No worry, you can add this simple line in the top of your script, and let the magic begin 🦄✨

# -*- coding: utf-8 -*-

With this line in the top, your script is encoded to utf-8 and can output emojis in the terminal. If the terminal is not able to show them, then, it’s the terminal problem, or maybe… you should get a coffee ☕

You Might Also Like

Leave a Reply