Search code examples
pythonunicodehex

how to replace Unicode Hex Character Code


my_string = "smart watch Xiaomi / Smart watches for women, men, children"

How can I get the character "/".

i do this: my_string.replace("/", "/") But I don't want to use this method.


Solution

  • html — HyperText Markup Language support

    html.unescape(s)

    Convert all named and numeric character references (e.g. >, >, >) in the string s to the corresponding Unicode characters. This function uses the rules defined by the HTML 5 standard for both valid and invalid character references, and the list of HTML 5 named character references.

    New in version 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'