a = time.time()
time.sleep(3)
b = time.time()
time_consuming = time.strftime("%H:%M:%S", time.localtime(b - a))
print(time_consuming)
Use the above code to run time.strftime. After formatting the time, there is always a default value for the hour. How did this 8-hour default value come about?
Due to time zone issues, time should not be used, datetime.timedelta should be used to calculate
Refer to the code below
The output is as follows:
8 hours is caused by time zone conversion: Beijing is the East Eighth District, and the time needs to be added forward by 8 hours.