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()