0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

絵文字を一文字ずつ処理する方法

Posted at

結論

emojiモジュールを使うと、できます。

import emoji
text="👧🏻"
emoji.replace_emoji(text,replace=lambda e, data_dict:print(e,end=" "))
# 👧🏻

解説

一般的に、Pythonで一文字ずつ処理したい場合、これでいけます。

text="ABCD"
[print(e,end=" ") for e in list(text)]
#A B C D

しかし、ZWJ emojiが含まれている状態で行うとうまくいきません。

text="👧🏻"
[print(e,end=" ") for e in list(text)]
# 👧 🏻

参考

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?