Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errno13, Permission denied when trying to read file

I have created a small python script. With that I am trying to read a txt file but my access is denied resolving to an no.13 error, here is my code:

import time
import os

destPath = 'C:\Users\PC\Desktop\New folder(13)'
for root, dirs, files in os.walk(destPath):

f=open(destPath, 'r')
.....
like image 236
We're All Mad Here Avatar asked Dec 27 '15 06:12

We're All Mad Here


1 Answers

Based on the name, I'm guessing that destPath is a directory, not a file. You can do a os.walk or a os.listdir on the directory, but you can't open it for reading. You can only call open on a file.

Maybe you meant to call open on one or more of the items from files

like image 176
Gary van der Merwe Avatar answered Sep 18 '22 17:09

Gary van der Merwe