python的假如路径不存在如何写

写python的假如路径不存在的方法:

使用if语句判断“os.path.exists()”的返回值是否是false,如果是false,则该路径不存在

示例代码如下:

import os
if os.path.exists("kkkk.txt") == False:
    # os.makedirs()
    print("该路径不存在")

执行结果如下:

微信截图_20200608102533.jpg

更多Python知识,请关注:云海天python教程网!!

来源:PY学习网:原文地址:https://www.py.cn/article.html

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » python的假如路径不存在如何写