在 python 的当前工作目录中查找具有特定名称的文件是否存在

Find if the file with specific name exists in the current working directory in python

提问人:David Jackson 提问时间:2/10/2020 更新时间:2/10/2020 访问量:53

问:

如何检查python当前工作目录中是否存在具有特定名称的文件? 我尝试关注但出现错误

import os
os.path.abspath(os.getcwd()).isfile('xyz.csv')

评论

1赞 AMC 2/10/2020
这回答了你的问题吗?如何检查文件是否存在,没有异常?

答:

0赞 johnramsden 2/10/2020 #1

os.path.exists(路径)

import os
os.path.exists(os.path.join(os.path.abspath(os.getcwd()), 'xyz.csv')