1 獲取當前腳本的路徑:
current_dir = sys.path[0]
2 創建一個文件路徑:
fail_img_path=os.path.join(str(current_dir) + '/register_result' + "/register_fail_img/"+ str(otherStyleTime))
3 拷貝文件:
import shutil
cp_scrip_path = os.path.join(fail_img_path,"Register_pics.py")
shutil.copyfile(py_script_file,cp_scrip_path)
4 判斷文件目錄是否存在
if ( os.path.exists(fail_img_path) is not True):
os.makedirs(fail_img_path)
5 逐行讀取文件
with open(log_path,'r') as f1:
print("==================")
list1 = f1.readlines()