2006年12月19日 星期二 12:30
Python 2.5 (r25:51908, Dec 18 2006, 21:43:53) [GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> fp=open('test.flag','rb') >>> c=fp.read(1) >>> c&3 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for &: 'str' and 'int' >>> c '\x14' >>> print c >>> from ctypes import * >>> a = c_char(c) >>> a c_char('\x14') >>> a&3 Traceback (most recent call last): File " ", line 1, in TypeError: unsupported operand type(s) for &: 'c_char' and 'int' >>> i=c_byte(c) Traceback (most recent call last): File " ", line 1, in TypeError: int expected instead of str instance >>> n=c_byte(a) Traceback (most recent call last): File " ", line 1, in TypeError: int expected instead of c_char instance >>> n=c_int(a) Traceback (most recent call last): File " ", line 1, in TypeError: int expected instead of c_char instance >>>
2006年12月19日 星期二 12:42
¿ÉÒÔÊÔÒ»ÊÔarray»òÕßstructÄ£¿é 2006/12/19, brightman <fenyon在126.com>: > > Python 2.5 (r25:51908, Dec 18 2006, 21:43:53) > [GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> fp=open('test.flag','rb') > >>> c=fp.read(1) > >>> c&3 > Traceback (most recent call last): > File "", line 1, in > TypeError: unsupported operand type(s) for &: 'str' and 'int' > >>> c > '\x14' > >>> print c > > >>> from ctypes import * > >>> a = c_char(c) > >>> a > c_char('\x14') > >>> a&3 > Traceback (most recent call last): > File "", line 1, in > TypeError: unsupported operand type(s) for &: 'c_char' and 'int' > >>> i=c_byte(c) > Traceback (most recent call last): > File "", line 1, in > TypeError: int expected instead of str instance > >>> n=c_byte(a) > Traceback (most recent call last): > File "", line 1, in > TypeError: int expected instead of c_char instance > >>> n=c_int(a) > Traceback (most recent call last): > File "", line 1, in > TypeError: int expected instead of c_char instance > >>> > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061219/3efd138b/attachment.html
2006年12月19日 星期二 12:53
On 12/19/06, brightman <fenyon在126.com> wrote: > Python 2.5 (r25:51908, Dec 18 2006, 21:43:53) > [GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> fp=open('test.flag','rb') > >>> c=fp.read(1) > >>> c&3 > Traceback (most recent call last): > File "", line 1, in > TypeError: unsupported operand type(s) for &: 'str' and 'int' > >>> c > '\x14' 可以使用ord(c)将一个字符转为int呀。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2006年12月19日 星期二 14:10
you may get the ascii code first, then do the bitwise operations. following code for your information >>> s = 'test' >>> ord(s[0]) & 7 4 >>> ord(s[1]) & 7 5 >>> ord(s[2]) & 7 3 >>> ord(s[3]) & 7 4 >>> -- Best Regards, Leo Jay
Zeuux © 2025
京ICP备05028076号