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

写python的假如路径不存在的方法:
使用if语句判断“os.path.exists()”的返回值是否是false,如果是false,则该路径不存在
示例代码如下:
import os
if os.path.exists("kkkk.txt") == False:
# os.makedirs()
print("该路径不存在")
执行结果如下:

更多Python知识,请关注:云海天python教程网!!
来源:PY学习网:原文地址:https://www.py.cn/article.html

