推荐学习书目
› 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
saximi
V2EX  ›  Python

如何 16 进制转义

  •  
  •   saximi · Aug 17, 2017 · 3098 views
    This topic created in 3339 days ago, the information mentioned may be changed or developed.
    非 ASCII Unicode 字符可以以十六进制转移(\xNN )编写到一个字符串中。
    请问程序如何写呢?
    谢谢
    4 replies  •  2017-08-18 15:57:34 +08:00
    izoabr
        1
    izoabr  
       Aug 17, 2017
    就这么写
    ysc3839
        2
    ysc3839  
       Aug 18, 2017 via Android
    你的意思是,有一段\x 转义的字符串,你要转换成 bytes?
    NoAnyLove
        3
    NoAnyLove  
       Aug 18, 2017
    完全不知道在说什么,Orz,我猜是这个意思?

    ```python3
    s = "Hello\n 中文\nWorld"
    ss = ''.join('\\x%02X' % b for b in s.encode('utf-8'))
    print(ss)
    ```
    860670496
        4
    860670496  
       Aug 18, 2017
    当然用键盘直接敲\xNN 啊……对,不要用马克笔往屏幕上画
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   965 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 19:08 · PVG 03:08 · LAX 12:08 · JFK 15:08
    ♥ Do have faith in what you're doing.