f = r'/mnt/data/dd/deeplearning/dataset/data/tfrecords'
# f = open(f)
print(os.path.exists(f))
true就是存在,然後一層層地判斷
讀取檔案的絕對路徑
path=os.path.abspath(os.path.join(current,os.path.pardir,'dataset/data'))
加入abspath以後輸出為
/mnt/data/aa/deeplearning/dataset/data
不加abspath
path=os.path.join(current,os.path.pardir,'dataset/data')
輸出為/mnt/data/aa/deeplearning/finalwork/../dataset/data
os.path.pardir為上一級,../
不加pardir
os.path.join(current,'dataset/data')
輸出/mnt/data/aa/deeplearning/finalwork/dataset/data
加上以後
os.path.join(current,os.path.pardir,'dataset/data')
輸出/mnt/data/aa/deeplearning/dataset/data
from imp import reload
reload(anno_func)
# 轉換成one_hot編碼
target_classes=
n_class=len(target_classes)
classes=np.array([int(target_classes[i]) for i in target_classes])
label = tf.cast(classes, tf.int32)
label = tf.one_hot(label,n_class,1,0)
sess=tf.session()
print(sess.run(label))
sess.close()
from imp import reload
reload(anno_func)
target_classes=
n_class=len(target_classes)
classes=np.array([int(target_classes[i]) for i in target_classes])
label = tf.cast(classes, tf.int32)
label = tf.one_hot(label,n_class,1,0)
sess=tf.session()
print(sess.run(label))
sess.close()
shell 判斷乙個檔案或者目錄是否存在
bin bash program 判斷乙個檔案或者目錄是否存在 history 01 04 2011 saint first releas path bin sbin usr bin usr sbin usr local bin usr local sbin bin export path read...
複製乙個檔案或者從乙個資源獲取乙個檔案並複製
複製乙個檔案或者從乙個資源獲取乙個檔案並複製 param unknown type source 乙個檔名或者乙個資源,如 source param unknown type fname 另存為的檔名 function copy from source source,fname fwrite fil...
python中判斷乙個檔案是否存在
你可以使用os.path.isfile,如果存在,它會返回true.如下 import os.path os.path.isfile fname 或者使用os.path.exists import os.path os.path.exists file path isfile和exists有一些區別...