1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Pythonで文字列から絵文字を処理する demoji

Last updated at Posted at 2023-08-20

ライブラリ

使い方

例文

s = "「目標達成日誌」をつけると成功確率がアップ!🐶👨👩👦"

辞書型に変換する findall(string: str) -> Dict[str, str]

demoji.findall(s)

{'👨': 'man', '🐶': 'dog face', '👩': 'woman', '👦': 'boy'}

リストに変換する findall_list(string: str, desc: bool = True) -> List[str]

demoji.findall_list(s)

['dog face', 'man', 'woman', 'boy']

絵文字を置換する replace(string: str, repl: str = "") -> str

demoji.replace(s, " :cat")

'「目標達成日誌」をつけると成功確率がアップ! :cat :cat :cat :cat'

説明を追記する replace(string: str, repl: str = "") -> str

demoji.replace_with_desc(s, " animal:")

'「目標達成日誌」をつけると成功確率がアップ! animal:dog face animal: animal:man animal: animal:woman animal: animal:boy animal:'
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?