os.listdir path error
Jerry Hill
malaclypse2 at gmail.com
Fri Aug 3 16:05:10 EDT 2007
On 8/3/07, vedrandekovic at v-programs.com <vedrandekovic at v-programs.com> wrote:
> Hello
>
> Here is my simple listdir example:
>
> >>> import os
> >>> os.listdir("C:\Python24\") # This directory relly exists
>
> Here is my error:
>
> WindowsError: [Errno 3] The system cannot find the path specified: 'l/
> *.*'
That's a somewhat surprising error. Under 2.5, I get a more helpful
error message:
>>> import os
>>> os.listdir("C:\Python25\")
SyntaxError: EOL while scanning single-quoted string
That's because I've escaped the closing quote of the string with \".
Use this instead:
>>> os.listdir("C:\\Python25\\")
or
>>> os.listdir("C:/Python25/")
since windows is usually happy to use forward slashes instead of
backslashes in directory names.
--
Jerry
More information about the Python-list
mailing list