非诚勿扰王佳牵手视频,苏b935nl,3岁育儿知识
第一种方法、os这个库里的os.path.exists()函数提供了这种用法,具体用法如下
import os import time time_start = time.time() file_path = '/home/hjxu/PycharmProjects/01_cats_vs_dogs/111.jpg' if os.path.exists(file_path): print 'yes' else: print("' file_path '"+ file_path + "' Not found'") time_end = time.time() print (time_end - time_start) #'0.00031876'
第二种方法、tensorflow也包含了这个功能
主要是tensorflow.python.platform 里面的gfile函数,废话不多说,直接上代码
import time from tensorflow.python.platform import gfile if not gfile.Exists(file_path): #判断文件和文件夹是否存在 print("Image directory '" + file_path + "' not found.") time_end = time.time() print (time_end - time_start) #0.0003309249
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python爬虫:Request Payload和Form Data的简单区别说明
浅谈Python中threading join和setDaemon用法及区别说明
Python3-异步进程回调函数(callback())介绍
python继承threading.Thread实现有返回值的子类实例
Python中使用threading.Event协调线程的运行详解
网友评论