Top of my head:
Open the file for binary reading at the start: file('project_release.a',
'rb').
Later, open a file (not necessarily the same one) for writing:
file('project_release2.a',
'wb')Cheers, Imri On Sun, Dec 27, 2009 at 3:41 PM, Yitzhak Wiener <[email protected]>wrote: > 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. > _____________________________________________________________________ > > _______________________________________________ > Python-il mailing list > [email protected] > http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il > > -- Imri Goldberg -------------------------------------- http://plnnr.com/ - automatic trip planning http://www.algorithm.co.il/blogs/ -------------------------------------- -- insert signature here ----
_______________________________________________ Python-il mailing list [email protected] http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
