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("文件不存在!!!!")
相关推荐
love_muming14 小时前
二叉树操作全解析:从递归到层序遍历
java·数据结构·算法·二叉树
小的~~14 小时前
ThreadLocal 、InheritableThreadLocal 与 TransmittableThreadLocal 的进阶指南
java·开发语言
北极糊的狐14 小时前
钉钉小程序报错data.formatTime is not a function是因为 axml 模板中不能直接调用 Page 内自定义方法!
java·小程序·钉钉
FriendshipT14 小时前
Ultralytics:解读 YOLO26 知识蒸馏
人工智能·pytorch·python·深度学习·yolo
BUG研究员_14 小时前
工具绑定与调用
python·agent
苏灿烤鱼14 小时前
AI Agent 深拆 | 图能让 AI 决策可追责吗?Semantica 登顶拆解
python·github·agent
Sirius.z1 天前
第R6周:LSTM实现糖尿病探索与预测
python
名字还没想好☜1 天前
Python f-string 进阶:数字格式化、对齐填充、调试 = 号与嵌套表达式
开发语言·数据库·python·字符串格式化·f-string
·薯条大王1 天前
经济实惠玩云服务器|一台云服务器多人共用,子账号配置教程
java·linux·运维·服务器·汇编·c++·python
Dxy12393102161 天前
Python 如何使用 MySQL 的事务
python·mysql