|
生成截图用的
- 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')
复制代码 |
|