[Python] Come scrivere un array di bytes in un file binario

Patrizio.Ferlito a b-source.ch Patrizio.Ferlito a b-source.ch
Lun 1 Ott 2007 14:26:58 CEST


Ciao a tutti,
 
non uso direttamente python ma lo uso indirettamente da WLST (weblogic scripting tool).
 
Ho un array di bytes da scrivere in un file binario, il codice è il seguente:
 
fileName = 'my.jar'
bytes = ...
file = open(fileName, 'wb')
file.write(String(bytes))
file.close()
 
ma se faccio una verifica sul file prodotto:
 
jar tvf my.jar
java.util.zip.ZipException: too many length or distance symbols
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:140)
        at java.util.zip.ZipInputStream.read(ZipInputStream.java:139)
        at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:91)
        at sun.tools.jar.Main.list(Main.java:743)
        at sun.tools.jar.Main.run(Main.java:191)
        at sun.tools.jar.Main.main(Main.java:903)

Quale dovrebbe essere l'approccio corretto?
 
Vi ringrazio
ferp
 


IMPORTANT: 
This e-mail transmission is intended for the named 
addressee(s)only. 
Its contents are private, confidential and protected 
from disclosure and should not be read, copied or
disclosed by any other person. 
If you are not the intended recipient, we kindly ask
you to notify the sender immediately by telephone 
(+41 (0)58 806 50 00), to redirect the message to the 
account "info a b-source.ch" and to delete this e-mail.
E-mail transmissions may be intercepted, altered or 
read by unauthorized persons and may contain viruses.
Therefore, it is recommended that you use regular mail
or courier services for any information intended to be 
confidential. However, by sending us messages through
e-mail, you authorize and instruct us to correspond by 
e-mail in the relevant matter. 
Thank you.
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: http://lists.python.it/pipermail/python/attachments/20071001/2d0f19d6/attachment.htm


Maggiori informazioni sulla lista Python