是否可以在Python中對C數據類型執行按位操作?關於C數據類型的python按位運算?
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import c_uint8
>>> foo = c_uint8(4)
>>> foo << 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for <<: 'c_ubyte' and 'int'
>>>
也許試試int(foo)<< 1或將'1'強制轉換爲'c_ubyte – inspectorG4dget