Unescaping Characters in a String with Python

前端 未结 2 740
鱼传尺愫
鱼传尺愫 2021-01-12 14:03

I made a JSON request that gives me a string that uses Unicode character codes that looks like:

s = \"\\u003Cp\\u003E\"

And I want to conve

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 14:18

    If the data came from JSON, the json module should already have decoded these escapes for you:

    >>> import json
    >>> json.loads('"\u003Cp\u003E"')
    u'

    '

提交回复
热议问题