Possible Duplicate:
How do I manipulate bits in Python?
这是我的代码:
int val = 0xAA;
int Bit, i;
for (i = 0; i < sizeof(Val)*8; i++) {
Bit = 1<<i;
if (Val & Bit) {
printf("Found a bit \n");
}
}
我是 C 语言人员,我需要用 Python 来完成此操作。有人可以帮忙吗?
最佳答案
根据文档,您可以按照 C: 中的方式进行操作
关于python - Python 中如何进行位运算?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13995285/