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

求科普python的位运算符「^」

  •  
  •   passluo · Jan 6, 2013 · 3051 views
    This topic created in 5015 days ago, the information mentioned may be changed or developed.
    不说话,看代码:

    for x in xrange(0,10):
    print x , 2^x , bin(2^x) , bin(2)

    输出结果

    0 2 0b10 0b10
    1 3 0b11 0b10
    2 0 0b0 0b10
    3 1 0b1 0b10
    4 6 0b110 0b10
    5 7 0b111 0b10
    6 4 0b100 0b10
    7 5 0b101 0b10
    8 10 0b1010 0b10
    9 11 0b1011 0b10

    只能想明白x=0,1,2的时候位运算的结果。但是从x=3开始就不明白了。。有大神不吝赐教的么?
    1 replies
    passluo
        1
    passluo  
    OP
       Jan 6, 2013
    好的。。。我犯傻了。。大家忽略我吧~

    结题~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   865 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:34 · PVG 03:34 · LAX 12:34 · JFK 15:34
    ♥ Do have faith in what you're doing.