Search code examples
python-3.xtweepytwitterapi-python

How do I embed emoji into Tweepy status text?


I have the following code that allows me type a text on the console that then is sent as a comment to tweets.

How can I embed emojis into this?

For example the emoji code for a smile is "U+1F600". When I add this as an entry as follows on the console:

"This is a smile U+1F600", the literal code is appearing on the tweet on the browser instead of the emoji image.

comment = input("[Reply with Comment to tweet:] ")                    
comment_formated="@{0} {1}".format(screen_name,comment)
api.update_status(status = comment_formated, in_reply_to_status_id = id_str)

Please how can I change this so that the picture emojis appear on the browser?


Solution

  • You should copy the emoji from other source like emojipedia and paste it in console when you want it. it will not appear as an emoji in the console, but it will appear correctly on twitter.

    console image

    "This is a smile 😀"

    Alternatively you can use Bytes directly, for example typing \xF0\x9F\x98\x81

    you can find all bytes data (UTF-8) for emojis here