【问题标题】:how to replace Unicode Hex Character Code如何替换 Unicode 十六进制字符代码
【发布时间】:2022-11-19 00:38:46
【问题描述】:
my_string = "smart watch Xiaomi / Smart watches for women, men, children"

我怎样才能得到字符“/”。

我这样做:my_string.replace("/", "/") 但我不想使用这种方法。

【问题讨论】:

    标签: python unicode hex


    【解决方案1】:

    html — HyperText Markup Language support

    html.unescape(s)

    转换所有命名和数字字符引用(例如>>,>)中的字符串s到对应的Unicode 人物。此函数使用 HTML 5 定义的规则 有效和无效字符引用的标准,以及the list of HTML 5 named character references

    3.4 版中的新功能。

    my_string = "smart watch Xiaomi / Smart watches for women, men, children"
    import html
    html.unescape(my_string)
    # 'smart watch Xiaomi / Smart watches for women, men, children'
    

    【讨论】:

      猜你喜欢
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      • 2012-02-21
      • 1970-01-01
      • 2014-12-28
      • 1970-01-01
      • 2013-08-03
      相关资源
      最近更新 更多