【问题标题】:How to dynamically specify unicode string in Python?如何在 Python 中动态指定 unicode 字符串?
【发布时间】:2021-08-18 09:37:13
【问题描述】:

根据herehere,Python 允许使用 unicode 字符的名称来获取字符。

例如:

print('\N{large red circle}')
????

我正在尝试弄清楚如何在不知道名称的情况下使用上述功能。即类似:

name = "large red circle"
emoji = some_code(name) # some code to use the above to produce '\N{large red circle}' without third party packages like 'emoji'
print(emoji)
????

有什么建议吗?

谢谢

【问题讨论】:

    标签: python string unicode emoji


    【解决方案1】:

    好的,我找到了一种方法here

    import unicodedata
    name = "large red circle"
    emoji = unicodedata.lookup(name)
    print(emoji)
    ?
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-19
      • 2018-09-21
      • 2019-07-26
      • 2014-03-16
      相关资源
      最近更新 更多