Python oserror: [errno 22] invalid argument: emergence and solution

 

 1 if __name__ == '__main__':
 2     startime = time.strftime('%H:%M:%S')
 3     print("Start time is: %s" % startime)
 4 # Test path
 5 test_dir = '. /t/test_case'
 6 # Report path
 7 report_dir = '. /t/report/'
 8 
 9 now = time.strftime('%Y-%m-%d_%H:%M:%S')
10 # Create the full report file
11     filename = report_dir + now + '_report.html'
12     fp = open(filename,'wb')

See!! Look at the ninth line, there is a problem with the acquisition time of now!!! Can’t use colon: can’t use colon: can’t use colon: can’t use colon: important things say three times

It is amended as follows:

1 if __name__ == '__main__':
 2     startime = time.strftime('%H:%M:%S')
 3     print("Start time is: %s" % startime)
 4 # Test path
 5 test_dir = '. /t/test_case'
 6 # Report path
 7 report_dir = '. /t/report/'
 8 
 9 now = time.strftime('%Y-%m-%d_%H_%M_%S')
10 # Create the full report file
11     filename = report_dir + now + '_report.html'
12     fp = open(filename,'wb')

Similar Posts: