場景:生成截圖的時候失敗
阿新 • • 發佈:2017-11-18
local jpg oca strftime git screens str span get
生成截圖用的
currentTimeToS = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
currentTimeToD = time.strftime("%Y-%m-%d", time.localtime(time.time())
path = ‘C:\\Git\\Intelligent correction‘ + ‘\\‘ + currentTimeToD + ‘\\‘ + currentTimeToS + ‘.jpg‘ driver.get_screenshot_as_file(‘C:\\Git‘+‘\\‘+currentTimeToD+‘\\‘+currentTimeToS+‘.jpg‘)
由於“currentTimeToD”這個文件夾不存在,所以不能創建成功
解決方法:
makedirs()方法 來遞歸創建目錄
currentTimeToS = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) currentTimeToD = time.strftime("%Y-%m-%d", time.localtime(time.time())) path = ‘C:\\Git\\Intelligent correction‘ + ‘\\‘ + currentTimeToD + ‘\\‘ + currentTimeToS + ‘.jpg‘ os.makedirs(path) driver.get_screenshot_as_file(‘C:\\Git‘+‘\\‘+currentTimeToD+‘\\‘+currentTimeToS+‘.jpg‘)
場景:生成截圖的時候失敗