我想知道是否有任何方法可以让我获得sudo访问权限。这只适用于Linux。
# get machine's username
userMachine = getpass.getuser()
# education > school's name > year
makeSchoolPath = "/home/userMachine/Education/schoolInput/str(yearCourse)"
os.makedirs(makeSchoolPath)
# last path, but also creates a leaf directory for each subject
dict2 = {}
for key, value in dict.items():
dict2 ['path' + value] = "/home/userMachine/Education/schoolInput/str(yearCourse/value"
for value2 in dict2.values():
os.mkdir(value2) 我收到错误:“发生异常:主目录错误13权限被拒绝:‘/ PermissionError /userMachine’”。我读到我应该写
chown -R user-id:group-id /path/to/the/directory但我不想搞砸任何事情,我有点害怕,因为这意味着“更换所有者”。
感谢您阅读《好人》:)
发布于 2020-05-04 11:55:17
如果您使用的是Linux,那么只需使用sudo python <your file name.py>运行您的代码。
发布于 2020-05-04 11:56:13
我非常确定如果你输入“sudo python file.py”,你的代码应该有sudo perm。告诉我这有没有用。
https://stackoverflow.com/questions/61584893
复制相似问题