How to properly iterate over unicode characters in Python

前端 未结 2 597
走了就别回头了
走了就别回头了 2021-01-25 05:26

I would like to iterate over a string and output all emojis.

I\'m trying to iterate over the characters, and check them against an emoji list.

However, python se

2条回答
  •  被撕碎了的回忆
    2021-01-25 05:44

    Try this,

    import re
    re.findall(r'[^\w\s,]', my_list[0])
    

    The regex r'[^\w\s,]' matches any character that is not a word, whitespace or comma.

提交回复
热议问题