推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
MiketsuSmasher
V2EX  ›  Python

Python ascii()函数的逆操作

  •  
  •   MiketsuSmasher · Sep 18, 2021 · 3261 views
    This topic created in 1841 days ago, the information mentioned may be changed or developed.
    >>> ascii('泷夜叉姬')
    "'\\u6cf7\\u591c\\u53c9\\u59ec'"
    

    如何将"'\\u6cf7\\u591c\\u53c9\\u59ec'"还原回去?

    5 replies  •  2021-09-22 09:50:09 +08:00
    matrixji
        1
    matrixji  
       Sep 18, 2021
    >>> eval(ascii('泷夜叉姬'))
    '泷夜叉姬'
    >>>
    getcharch
        2
    getcharch  
       Sep 18, 2021
    ascii('泷夜叉姬').encode('ascii').decode('unicode_escape')
    iBugOne
        3
    iBugOne  
       Sep 18, 2021 via Android   ❤️ 1
    >>> import ast
    >>> ast.literal_eval(ascii('泷夜叉姬'))
    '泷夜叉姬'
    >>>
    yuguorui96
        4
    yuguorui96  
       Sep 19, 2021
    frostming
        5
    frostming  
       Sep 22, 2021
    #2 是「正」解,literal_eval 是次优解,eval 是歪解
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   762 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 21:00 · PVG 05:00 · LAX 14:00 · JFK 17:00
    ♥ Do have faith in what you're doing.