File Read issue by using module binascii

Peter Otten __peter__ at web.de
Sat Apr 27 06:57:09 EDT 2013


Jimmie He wrote:

> When I run the readbmp on an example.bmp(about 100k),the Shell is become
> to "No respose",when I change f.read() to f.read(1000),it is ok,could
> someone tell me the excat reason for this? Thank you in advance!
> 
> Python Code as below!!
> 
> import binascii
> 
> def read_bmp():
>     f = open('example.bmp','rb')
>     rawdata = f.read()                       #f.read(1000) is ok
>     hexstr = binascii.b2a_hex(rawdata)       #Get an HEX number
>     bsstr = bin (int(hexstr,16))[2:]
>     f.close()
>     print('bin: ',bsstr,type(bsstr))
>     return

What shell are you using? The one provided by Idle?




More information about the Python-list mailing list