- #1
mynick
- 34
- 0
I am fiddling with python v2.7.5,i am using Pyscripter version 2.5.3.0 x86 to write my program and i do not know how to deal with this problem when i run my program:
PROBLEM:
___________________________________________
IOError:[Errno 2] No such file or directory:'words.txt' |
___________________________________________|
My Settings in Pyscripter:
In my Pyscripter menu bar: tools->python path...->here opens a pop up window which says: Ordered list of file paths:
C:\Python27
C:\Python27\lib\site-packages
C:\Python27\lib
(some more...)
I have placed my 'words.txt' in all three file paths i mention above.For example,C:\Python27 it does contain my 'words.txt' among other things.
THE CODE:
N=13
def findme(N):
...i=1
...fin=open('words.txt')
...for i in range(N):
...readaline=fin.readline()
...line=readaline.strip()
...for letter in line:
....if letter!='a':
.....return line
findme(13)
what i want the code to do: open and search my txt file :'words.txt' one line at a time and print on the screen all the words that do not have the letter 'a' in them. The contents of my words.txt are in this fashion:
aaaaaaa
bbbbbbb
assdd
erwe
sddfsdfsfgsgsg
How do i solve the IOError:[Errno 2] No such file or directory:'words.txt' ?
(sorry for the dots in my code,in my pyscripter of course i do not use dots,i used them here to create indents and make it easier to read the code)
PROBLEM:
___________________________________________
IOError:[Errno 2] No such file or directory:'words.txt' |
___________________________________________|
My Settings in Pyscripter:
In my Pyscripter menu bar: tools->python path...->here opens a pop up window which says: Ordered list of file paths:
C:\Python27
C:\Python27\lib\site-packages
C:\Python27\lib
(some more...)
I have placed my 'words.txt' in all three file paths i mention above.For example,C:\Python27 it does contain my 'words.txt' among other things.
THE CODE:
N=13
def findme(N):
...i=1
...fin=open('words.txt')
...for i in range(N):
...readaline=fin.readline()
...line=readaline.strip()
...for letter in line:
....if letter!='a':
.....return line
findme(13)
what i want the code to do: open and search my txt file :'words.txt' one line at a time and print on the screen all the words that do not have the letter 'a' in them. The contents of my words.txt are in this fashion:
aaaaaaa
bbbbbbb
assdd
erwe
sddfsdfsfgsgsg
How do i solve the IOError:[Errno 2] No such file or directory:'words.txt' ?
(sorry for the dots in my code,in my pyscripter of course i do not use dots,i used them here to create indents and make it easier to read the code)
Last edited: