os.listdir path error

V

vedrandekovic

Hello

Here is my simple listdir example:

Here is my error:

WindowsError: [Errno 3] The system cannot find the path specified: 'l/
*.*'

Regards,
Vedran
 
J

Jerry Hill

Hello

Here is my simple listdir example:

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:

SyntaxError: EOL while scanning single-quoted string

That's because I've escaped the closing quote of the string with \".
Use this instead:

since windows is usually happy to use forward slashes instead of
backslashes in directory names.
 
K

kyosohma

Hello

Here is my simple listdir example:

Here is my error:

WindowsError: [Errno 3] The system cannot find the path specified: 'l/
*.*'

Regards,
Vedran

I get "SyntaxError: EOL while scanning single-quoted string", which is
what should happen when you escape the double-quotes at the end. Not
sure how you're getting that WindowsErrors.

If I do os.listdir('c:\python24') instead, it works fine.

Mike
 
T

Tim Roberts

I get "SyntaxError: EOL while scanning single-quoted string", which is
what should happen when you escape the double-quotes at the end. Not
sure how you're getting that WindowsErrors.

If I do os.listdir('c:\python24') instead, it works fine.

Yes, but only by accident. It will fail again if you try to do
os.listdir('c:\tmp'). You need to use the right quoting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top