# python os.path.isfile() os.path.isdir() os.path.exists()
#https://shengyu7697.github.io/python-os-path-isdir/
#https://shengyu7697.github.io/python-os-path-isfile/
import os
dir="ppp"
print("—–確認目錄開始——")
#print(os.path.isdir(dir))
print ("os.path.isdir(範例)")
checkdir=os.path.isdir(dir)
if checkdir:
print("目錄存在")
else:
print("目錄不存在")
print ("os.path.exists(範例)")
checkdir=os.path.exists(dir)
if checkdir:
print("目錄存在")
else:
print("目錄不存在")
#確認檔案開始
print("—–確認檔案開始——")
print ("os.path.isfile(範例)")
files="jjj.txt"
checkfile=os.path.isfile(files)
if checkfile:
print("檔案存在")
else:
print("檔案不存在")
print ("os.path.exits(範例)")
files="jjj.txt"
checkfile=os.path.exists(files)
if checkfile:
print("檔案存在")
else:
print("檔案不存在")