How to extract emojis and flags from strings in Python?
问题 import emoji def emoji_lis(string): _entities = [] for pos,c in enumerate(string): if c in emoji.UNICODE_EMOJI: print("Matched!!", c ,c.encode('ascii',"backslashreplace")) _entities.append({ "location":pos, "emoji": c }) return _entities emoji_lis("👧🏿 مدیحہ🇵🇰 así, se 😌 ds 💕👭") Matched!! 👧 \U0001f467 Matched!! 🏿 \U0001f3ff Matched!! 😌 \U0001f60c Matched!! 💕 \U0001f495 Matched!! 👭 \U0001f46d My code is working of all other emoji's but how can I detect country flags 🇵🇰? 回答1: Here is an article