2
0

More than 1 year has passed since last update.

100万人に伝えたい!失敗を乗り超えた話を共有しよう

Pythonで絵文字を認識する方法(無駄記事)

Last updated at Posted at 2023-07-28

概要

絵文字同士の比較をする際、そのまま(e.g. "👏" == "👏")だとエラーが出た。
ord()をかませると上手くいった。

a = "👏"
if len(a) == 1 and ord(a) == ord("👏"):
    print("OK")

#console: OK

経緯

Discord Bot 作成中、絵文字メッセージがトリガーの関数を実装しようとした。

振り返り

執筆にあたりやり直したところ、直接比較で全く問題なかった。
ダブルクオーテーションを付け損ねていたのだのだろうか。

2
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0