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("文件不存在!!!!")
相关推荐
行者-全栈开发6 小时前
SpringBoot + GraalVM 原生编译实战:启动时间从8秒到0.5秒的极致优化
java·spring boot·后端
zly35006 小时前
esxi安装 windows2000 鼠标不动
运维·服务器
tryCbest6 小时前
Python 爬虫从入门到实战(一):基础篇——从零写出第一个爬虫
开发语言·爬虫·python
CoderYanger7 小时前
Java EE 进阶:10. MyBatis-Plus使用(第一弹)
java·spring boot·后端·sql·spring·java-ee·mybatis
无小道7 小时前
Python语句的特色
python·语句
LabVIEW开发7 小时前
Ethernet/IP 会话无效 -251723770
服务器·网络协议·tcp/ip
2601_967980118 小时前
python pytest如何编写测试
python·测试用例·pytest·函数·assert
2601_967980119 小时前
Python中heapq模块的各种用法实例
数据结构·python·算法·应用实例·heapq模块
大胖爱学习_MJ9 小时前
超越向量检索:用 Spring Boot + Neo4j 手搓 GraphRAG 知识图谱记忆
java·后端·python
RobinDevNotes9 小时前
24GB Mac 做数字人:声音放本地,画面租云端
人工智能·python·macos·开发工具