在Python中,我有一个像这样的组合表情符号:“👨”+“\u200D”+“🔧”
,通常表示为https://emojipedia.org/male-mechanic/ 。我想要一个 PNG 版本用作绘图点(在 matplotlib 中,如果有帮助的话)。有没有任何官方或非官方的地方可以将 unicode 版本的表情符号转换为 PNG 等效版本?
最佳答案
对于其他正在寻找答案的人,目前我正在使用 https://unicode.org/emoji/charts/full-emoji-list.html 中的 PNG。 ,使用解析网页的 hack,如下所示
class EmojiConverter:
def __init__(self):
import requests
import re
self.data = requests.get('https://unicode.org/emoji/charts/full-emoji-list.html').text
def to_base64_png(self, emoji, version=0):
"""For different versions, you can set version = 0 for , """
html_search_string = r"<img alt='{}' class='imga' src='data:image/png;base64,([^']+)'>" #'
matchlist = re.findall(html_search_string.format(emoji), self.data)
return matchlist[version]
e = EmojiConverter()
b64 = e.to_base64_png("👨"+"\u200D" + "🔧")
关于png - 以编程方式获取 unicode 表情符号的 PNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53721028/