python - 如何检查python中是否存在文件?

标签 python windows file

<分区>

Possible Duplicate:
Pythonic way to check if a file exists?

python如何判断一个文件是否存在?

在 Windows 中编写脚本

最佳答案

这很容易使用 os模块。

from os.path import exists
print exists("C:\somefile.txt")

关于python - 如何检查python中是否存在文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6908003/

相关文章:

Python,提取标签并获取单词的位置

python - 将按 pandas 数据框(多个但不是所有列)分组的数据从长转换为宽

windows - 从右键单击选项 (Windows 7-8) 的新建文件/文件夹选项中更改/添加/删除项目?

java - 使用 xPath 修改 XML 文件

Python - 回文函数 : Receiving error "list indices must be integers or slices, not str"

python - 不使用 virtualenv 时安装包的位置

windows - Maven 中的 Java_home

python - 从 Windows 迁移到 Linux

java - 使用 Stream 加载和处理文件

javascript - Reactjs 读取属性文件?