這裏是我的,我試圖在Mac OS X上運行代碼:如何擺脫「IO錯誤: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
而且我已經搜索一下,無法弄清楚爲什麼它不起作用。 背景信息:將文件從桌面移動到文檔時有效,但我認爲我需要以某種方式根用戶權限。即時在管理員帳戶。
source_file = r「/ Users /%s // ...」< - 2 // // 此外,字符串插值應該只是%var_username或%(var_username,) –