os模块:

path=os.path.join(os.path.dirname(os.path.dirname(__file__)),'images')

path:运行脚本的当前文件下的上一个文件的地址+images

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
os.path.dirname(__file__)

脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如:

python d:/pythonSrc/test/test.py

那么将输出 d:/pythonSrc/test


脚本是以相对路径被运行的, 那么将输出空目录,比如:

python test.py

那么将输出空字符串

 

将path的地址添加上‘image’

os.path.join(path,‘image’) 


判断是否有path文件夹

os.path.exists(path)

 

创建一个文件夹

os.mkdir(self.path)

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄