我得到一个权限错误时,试图保存屏幕截图从Sikuli在Windows下。执行捕获的代码是:
def CaptureScreenshot(self):
resultsDirectory = os.path.join('C','08 May 2013 11 34','myname.png')
screenshot = capture(self.screen)
print(screenshot)
shutil.move(screenshot,self.resultsDirectory)
当我打印capture
返回的屏幕截图路径时,我得到
D:\DOCUME~1\BUNNINGS\LOCALS~1\Temp\sikuli-scr-366782306192033926.png
运行代码时,出现以下错误:
Traceback (most recent call last):
File "__pyclasspath__/Tests/Tests.py", line 12, in tearDown
File "__pyclasspath__/Scripts/Screen.py", line 39, in CaptureScreenshot
File "C:\jython2.5.3\Lib\shutil.py", line 205, in move
copy2(src,dst)
File "C:\jython2.5.3\Lib\shutil.py", line 96, in copy2
copyfile(src, dst)
File "C:\jython2.5.3\Lib\shutil.py", line 52, in copyfile
fdst = open(dst, 'wb')
IOError: [Errno 13] Permission denied: 'C\\08 May 2013 11 34\\myname.png'
目标文件夹存在并且myname。png
是我试图给图像起的新名字。
我注意到目标文件夹的属性设置为“只读”。这是导致问题的原因吗?我无法更改只读属性;当我尝试时,它会返回只读。
路径中的C
后似乎缺少冒号。您现在正试图写入当前目录的子目录“C”。
试着把第二行改成:
resultsDirectory = os.path.join('C:','08 May 2013 11 34','myname.png')
^