Ciao Francesco, ti ringrazio per il suggerimento, provvedo a cambiarlo.
Il codice inizialmente era il seguente: bytes = ALSBConfigurationMBean.exportProjects(Collections.singleton(projectRef), None) file = open(fileName, 'wb') file.write(bytes) file.close() dove il metodo exportProjects ritorna un array di bytes. Ma ricevevo il seguente errore: [java] Problem invoking WLST - Traceback (innermost last): [java] File "/products/.../export.py", line 107, in ? [java] File "/products/.../export.py", line 79, in export [java] File "/products/.../utils.py", line 59, in writeBinaryFile [java] TypeError: write(): 1st arg can't be coerced to String dove la riga 59 in utils.py è proprio la: file.write(bytes) stavo quindi cercando di capire come potevo scrivere l'array di bytes in un file. grazie ferp -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Francesco Guerrieri Sent: lunedì, 1. ottobre 2007 14:44 To: Discussioni generali sul linguaggio Python Subject: Re: [Python] Come scrivere un array di bytes in un file binario On 10/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > 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() > Intanto il nome file è un built-in, è meglio non usarlo per una tua variabile. Quindi chiamalo per esempio output_file poi qual è lo scopo di quella chiamata a String? che funzione è ? sei sicuro che sia necessaria? dovrebbe normalmente bastare bytes = 'abc' output_file = open(fileName, 'wb') output_file.write(bytes) ciao francesco _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python 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 "[EMAIL PROTECTED]" 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. _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python