exists=false, but no complaint when i open it!?

s0suk3 at gmail.com s0suk3 at gmail.com
Thu May 15 17:13:51 EDT 2008


On May 15, 12:07 pm, globalrev <skanem... at yahoo.se> wrote:
> On 15 Maj, 19:04, globalrev <skanem... at yahoo.se> wrote:
>
> > when i try to write to the file...
>
> > Traceback (most recent call last):
> >   File "C:\Python25\myPrograms\netflix\netflix.py", line 10, in
> > <module>
> >     d.write('hej du galne kock')
> > IOError: [Errno 0] Error
>
> damn i take a break lol.
>
> r+ ldo when open file so i CAN write to it...

That traceback doesn't provide much help ("[Errno 0] Error"...), but I
remember that one time I got it when trying to write to a file opened
for reading. Make sure you're opening the file for writing (passing
"w" as the second argument to open(), or "wb" if you're writing binary
data). Also, as everyone keeps pointing out to you, watch out for
backslash scapes -- double the slashes ("\\", that really means a
single \ to Python), use forward slashes ("/", perhaps not the most
elegant solution, but it always works), or put an "r" next to the
string (r"your\path"). The last form is the easiest, but it only works
if you're typing a literal; you'll eventually need to double slashes
(e.g., for replacing something in a string: s.replace("/", "\\")).




More information about the Python-list mailing list