简体   繁体   中英

Permission error 13 Python 3.5.2

I have a problem opening a file with Python script in windows 10.

What I do is next:

I open my script as administrator in which create a new directory in the route:

C:\\ProgramData\\New_folder

Inside that folder I create a txt file:

C:\\ProgramData\\New_folder\\log.txt

After that the program put some text in the log.txt and finish.

Now I have to open the script normally not as admin and when the program start it launch an permission error 13 in the following line of code.

dirLog = 'C:\ProgramData\New_folder\log.txt'
output = open(dirLog, "a")

I really don't know what is happening here because I check the file created and it has read and write permissions.

it's of vital importance open the script as admin just the first time, the rest just normally.

This might be caused because of the level of permission that the folder is set at. There is a possible fix for this, but it could cause security issues in the future as far as permissions for that folder go. If you can afford to change the permission level of the folder, try this: navigate to ProgramData, right click on the folder, click 'Properties', then hit the 'Security' tab at the top, then check the permissions for users. If the read permission is set off, turn it on. Otherwise, try enabling the write permission.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM