描述
exists() 判断文件或路径是否存在。
exists() 接收两个参数,第一个为文件或路径,第二个为检测类型,文件或目录。
语法
以下是 exists() 的语法:
1 | exists(path, type='dir') |
参数
● path [str]:文件或路径。
● type [str]:dir:检测目录是否存在,file:检测文件是否存在。
返回值
返回布尔类型。
实例
以下展示了使用 exists() 的实例:
1 2 3 | from kyger.utility import existsprint(exists('static/404')) # 判断目录是否存在print(exists('static/kgcms.json', type='file')) # 判断文件是否存在 |
以上实例运行后输出的结果为:
1 2 | TrueFalse |
适应版本
v1.0.1








