[Tutor] Error writing to file...
x7-g5W_rt at earthlink.net
Fri Dec 25 21:38:37 CET 2009
Ken G. <beachkid <at> insightbb.com> writes:
> Do I need to convert a numeric random number to a string number?
Yes, as long as you open the file as "w" you need to use "repr()" [repr(int)].
If you want to save the integer, you need to open a file as "wb", write binary.
Check your documentation, both "wb" and "pickle" - I'm pretty new to Python, so
I won't try to advise you on the "read-only character buffer" mentioned in the
error message, but also look up "bytes" objects - they may work as long as your
integer range is in range(255).
Hope this helps,
More information about the Tutor