python判断文件是否存在

复制代码
import os 

test_path ="/Users/yxk/Desktop/test/GrayScale.tif"
if(os.path.exists(test_path)):
    print('文件存在!!!!')
else:
    print("文件不存在!!!!")

结果如下

代码

复制代码
import os 

test_path ="/Users/yxk/Desktop/testA/GrayScale.tif"
if(os.path.exists(test_path)):
    print('文件存在!!!!')
else:
    print("文件不存在!!!!")
相关推荐
m0_613856291 分钟前
如何解决宝塔面板Web端文件管理器打开目录时反应极其缓慢
jvm·数据库·python
wltx16882 分钟前
独立站搭建需要做氨氮检测仪展示吗?
人工智能·python
The_superstar62 分钟前
衡山派D133EBS入门笔记
笔记·python·c·衡山派·小曹越
Air_July5 分钟前
Brower User Web UI部署详细步骤
人工智能·python·测试工具
m0_6138562913 分钟前
mysql如何优化重复索引_mysql冗余索引查找与处理
jvm·数据库·python
四维迁跃14 分钟前
Python Web开发如何防范SQL注入_使用参数化查询与ORM实践
jvm·数据库·python
噜噜噜阿鲁~15 分钟前
python学习笔记 | 8.3、函数式编程-匿名函数
笔记·python·学习
YJlio19 分钟前
Windows Internals 读书笔记 10.3.3:Task Scheduler 架构详解
人工智能·windows·笔记·python·学习·chatgpt·架构
2401_8330336221 分钟前
如何自动更新SQL标签状态_利用触发器实现基于逻辑的状态机
jvm·数据库·python
信徒_24 分钟前
API 网关技术选型
java