python自動獲取項目路徑在windows和mac的不同
import os # 獲取項目路徑 project_path = os.path.abspath(os.path.join(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]), '.')) # test_case_path = project_path+"\\src\\test_case" test_case_path = project_path+"//src//test_case" # mac環境 # print u'日志路徑:'+log_path # 測試報告存儲路徑,並以當前時間作為報告名稱前綴 # 獲取到當前文件的目錄,並檢查是否有Report文件夾,如果不存在則自動新建Report文件 # report_path = project_path+"\\report\\" report_path = project_path+"//report//" # mac環境 if not os.path.exists(report_path): os.makedirs(report_path) report_name = report_path+time.strftime('%Y%m%d%H%S', time.localtime())