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

问题描述 投票:0回答:1

如何检查python当前工作目录中是否存在具有特定名称的文件?我尝试了以下操作,但给出了错误

import os
os.path.abspath(os.getcwd()).isfile('xyz.csv')
python
1个回答
0
投票

os.path.exists(path)

import os
os.path.exists(os.path.join(os.path.abspath(os.getcwd()), 'xyz.csv')
© www.soinside.com 2019 - 2024. All rights reserved.