Вот мой код, который я пытаюсь запустить на Mac OS X:Как избавиться от «IOError: 13„Разрешение отказано“» на Mac OS X
import getpass #Needed for fetching username
import shutil #Needed for moving Files
import os
var_username = getpass.getuser() #gets username and returns as variable
source_file = r"/Users/%s//Downloads/LogNLock/com.lognlock.loginhook.plist" %(var_username) #the destination of the source file
destination = r"/Library/LaunchAgents" #the target destination for the file to go
shutil.copy(source_file, destination) #moves the source file to the destination folder
И Я googled вокруг и не может понять, почему это не сработает. Фоновая информация: она работает при перемещении файлов с рабочего стола на документы, например, но я думаю, что мне нужно как-то узнать, как привилегии пользователя root. im на учетной записи администратора сейчас.
source_file = г "/ Users /% s // ..." <- 2 // 's Также строка интерполяции должна быть просто% var_username или% (var_username,) –