简体   繁体   English

权限错误13 Python 3.5.2

[英]Permission error 13 Python 3.5.2

I have a problem opening a file with Python script in windows 10. 我在使用Windows 10中的Python脚本打开文件时遇到问题。

What I do is next: 我接下来做的是:

I open my script as administrator in which create a new directory in the route: 我以管理员身份打开我的脚本,在该路径中创建一个新目录:

C:\\ProgramData\\New_folder C:\\ ProgramData \\ New_folder

Inside that folder I create a txt file: 在该文件夹中我创建了一个txt文件:

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

After that the program put some text in the log.txt and finish. 之后,程序在log.txt中放入了一些文本并完成。

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. 现在我必须通常不以管理员身份打开脚本,当程序启动时,在以下代码行中启动权限错误13。

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. 如果您能够更改文件夹的权限级别,请尝试以下操作:导航到ProgramData,右键单击文件夹,单击“属性”,然后点击顶部的“安全”选项卡,然后检查用户的权限。 If the read permission is set off, turn it on. 如果已设置读取权限,请将其打开。 Otherwise, try enabling the write permission. 否则,请尝试启用写入权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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