[Tutor] How to write list to file
Alan Gauld
alan.gauld at blueyonder.co.uk
Wed Jan 28 17:53:44 EST 2004
> print bytearray[0:bytetotal]
> outfile.write("[")
> for byte in bytearray[0:bytetotal]:
> outfile.write(byte)
> outfile.write("]")
Dunno why you get the result you do, but this seems a convoluted
way of writing the list to a file (depending what you want it
for of course). Whats wrong with
outfile.write(str(bytearray[0:bytesize]))
which should give you something very similar to:
> The print statement prints this:
>
> ['F', '8', '\t']
Since this is just the string representation of the list...
Alan G.
(Dodging the issue and dangerously simplifying! :-)
More information about the Tutor
mailing list