[Python-il] problem in script

Yitzhak Wiener Yitzhak.Wiener at dspg.com
Sun Dec 27 15:41:38 IST 2009


Hi Dear People,

 

As really beginner in Python, I tried to write a simple script that
opens a binary file and replace all appearance of some data with another
data.

It doesn't show me any error message, but file is not modified. Can you
help to understand why?

 

My script is as follows:

from array import array

a = array('H')

f =  file('project_release.a')

a.fromfile( f,100 )

 

# update the content

for i in a:

   if i == 0xFFFF:

       a[ a.index(i) ] = 0x7777

 

 

#update to new file

a.tofile(f)

 

 

Thanks,

Yitzhak

 


______________________________________________________________________
DSP Group, Inc. automatically scans all emails and attachments using MessageLabs Email Security System.
_____________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hamakor.org.il/pipermail/python-il/attachments/20091227/246b1e0d/attachment.htm 


More information about the Python-il mailing list