0

I'm new to Python and I'm having a problem I can't explain. While running:

>>> open('word.txt')

it returns: No such file or directory: 'words.txt', even if I have both files saved in the same place.

I've tried entering the entire file location, but still no luck.

Any help would be greatly appreciated, and thank you very much for your time

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vegaseat
0

Is it as simple as word.txt versus words.txt?

Try this:

import os
os.listdir('.')

If that gets an unexpected result, it should give you a good clue.

Edited by griswolf: n/a

0

If you run your Python code from the shell, you will most likely not be in the same directory as your file word.txt

Give this a try to show the current working directory the shell looks at ...

>>> import os; os.getcwd()
'C:\\Python26'
>>>

Also, if you use Unix, file names and path names are case sensitive.

Edited by vegaseat: unix

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.