【轉自https://www.cnblogs.com/Owen-ET/】
1 if __name__ == '__main__':
2 startime = time.strftime('%H:%M:%S') 3 print("開始時間為:%s" % startime) 4 #測試路徑 5 test_dir = './t/test_case' 6 #報告路徑 7 report_dir = './t/report/' 8 9 now = time.strftime('%Y-%m-%d_%H:%M:%S') 10 # 創建完整報告文件 11 filename = report_dir + now + '_report.html' 12 fp = open(filename,'wb')
看到沒有!!看第九行,now的獲取時間有問題!!!時分秒之間不能用冒號:,不能用冒號:,不能用冒號:,重要的事情說三遍!!!
修改如下:
1 if __name__ == '__main__': 2 startime = time.strftime('%H:%M:%S') 3 print("開始時間為:%s" % startime) 4 #測試路徑 5 test_dir = './t/test_case' 6 #報告路徑 7 report_dir = './t/report/' 8 9 now = time.strftime('%Y-%m-%d_%H_%M_%S') 10 # 創建完整報告文件 11 filename = report_dir + now + '_report.html' 12 fp = open(filename,'wb')