how to read a file in other directory in python

Posted by mazen.r.f on Stack Overflow See other posts from Stack Overflow or by mazen.r.f
Published on 2012-11-04T22:46:02Z Indexed on 2012/11/04 23:00 UTC
Read the original article Hit count: 197

Filed under:

i have a file its name is 5_1.txt in a directory i named it direct ,
how can i read that file using the instruction read.

i verified the path using :

os.getcwd()
os.path.exists(direct)

the result was
True

x_file=open(direct,'r')  

and i got this error :

Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
x_file=open(direct,'r')
IOError: [Errno 13] Permission denied

i don't know why i can't read the file ? any suggestion ?
thanks .

© Stack Overflow or respective owner

Related posts about python