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

求助: Python 字符串 '0x01' 转换成 数字

  •  
  •   jtsai · Apr 21, 2017 · 4034 views
    This topic created in 3341 days ago, the information mentioned may be changed or developed.

    int('0x01') 报错~~~ 咋办

    7 replies    2017-04-22 10:39:43 +08:00
    fy
        1
    fy  
       Apr 21, 2017   ❤️ 3
    int('0xaa01', 16)
    TerrenceSun
        2
    TerrenceSun  
       Apr 21, 2017
    int('0x01',0)
    nyanyh
        3
    nyanyh  
       Apr 21, 2017
    struct.pack('i', '0x01')
    Yingruoyuan
        4
    Yingruoyuan  
       Apr 21, 2017   ❤️ 1
    int(eval('0x01'))
    aristotll
        5
    aristotll  
       Apr 21, 2017
    @Yingruoyuan eval 性能不好吧
    phrack
        6
    phrack  
       Apr 22, 2017 via Android
    @aristotll 不用管 eval 的性能吧,谁会代码里到处是 eval 〒_〒
    Yingruoyuan
        7
    Yingruoyuan  
       Apr 22, 2017
    @aristotll
    @phrack
    @jtsai
    是的,这个比较适合救急用,楼上的 int('0xaa01', 16)是更好的方法
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2855 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 119ms · UTC 07:02 · PVG 15:02 · LAX 00:02 · JFK 03:02
    ♥ Do have faith in what you're doing.