表情符號是世界上增長最快的語言,有超過3000種表情符號。那麼,為什麼不開始在我們的python程式中使用表情符號。在本文中,您將學習如何在python中使用表情符號。
為了在python中使用表情符號,我們需要安裝一個emoji庫,開啟命令提示符並執行此命令。
pip install emoji
該命令將emoji在您的電腦上安裝該庫,現在您可以在python程式中使用表情符號了。
這個庫使用一個表情符號備忘單,以顯示該特定cheat._的表情符號
1 2 3 4 5 6 | >>> import emoji #This command will import emoji library in your program >>> print(emoji.emojize('Give a :thumbs_up: to this article.')) Give a to this article. >>> print(emoji.emojize('Give a :red_heart: to this article.')) Give a ? to this article. |
預設情況下,您只能使用表單中的少量表情符號, 如果需要使用其它emoji表情需要emoji.emojize(use_aliases=True)在程式碼中新增的完整串列
1 2 3 4 5 6 | >>> import emoji >>> print(emoji.emojize('Are you feeling :angry:', use_aliases=True)) Are you feeling >>> print(emoji.emojize('Dont forget to wear your :mask:', use_aliases=True)) Dont forget to wear your |