Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我以为它会等于 1<<7 == 128,但为什么它等于 1<<8 == 256?你能解释一下 x<<y + x<<z 运算的代数吗?
蟒蛇解释器
这是因为 python 的操作顺序,在左移运算符之前计算加法。表达式等价于
(1<<(3+1))<<4