Python WebDriver 代码优化:兼容低版本浏览器和 Firefox
import os
创建目录
def mkdir(path): # 去除首尾空格 path = path.strip() # 去除尾部 \ 符号 path = path.rstrip('\') # 判断路径是否存在 isExists = os.path.exists(path) # 如果不存在则创建目录 if not isExists: # 创建目录 try: os.makedirs(path) except OSError: print(f'Failed to create directory {path}') return False else: return True else: return False
原文地址: https://www.cveoy.top/t/topic/m2LP 著作权归作者所有。请勿转载和采集!