V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2013-01-06 19:31:30 +08:00 · 2396 次点击
    这是一个创建于 4128 天前的主题,其中的信息可能已经有所发展或是发生改变。
    不说话,看代码:

    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 条回复
    passluo
        1
    passluo  
    OP
       2013-01-06 19:47:06 +08:00
    好的。。。我犯傻了。。大家忽略我吧~

    结题~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1129 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:33 · PVG 02:33 · LAX 11:33 · JFK 14:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.