Python open of c:\ path Problem
Fredrik Lundh
fredrik at pythonware.com
Sat Aug 23 10:08:01 EDT 2008
Wayne Watson wrote:
> Python doesn't like this:
>
> junkfile = open('c:\tmp\junkpythonfile','w')
>
> I get
> junkfile = open('c:\tmp\junkpythonfile','w')
> IOError: [Errno 2] No such file or directory: 'c:\tmp\\junkpythonfile'
"\" is used as an escape character in string literals, so "\t" doesn't
mean what you think it does. see
http://docs.python.org/ref/strings.html
for details.
to work around this, use double backslashes ("foo\\bar"), raw strings
(r"foo\bar"), or, usually easiest, forward slashes ("foo/bar").
</F>
More information about the Python-list
mailing list