python步调计划运转功夫差

python步调计划运转功夫差

import datetime

# from time import time

time0 = datetime.datetime(2020,1,3,21,11,31,994824)

time1 = datetime.datetime(2020,1,3,21,11,32,765880)

interval = (time1 - time0).total_seconds() # 即使功夫差在1秒内,.seconds本领得出的截止为0

print(interval)

提防: 普遍遏制台输入的个位数前方会加上0,比方2020:01:03,21:12:09:031839,而写在datetime.datetime(…)中时,要把前方的0去掉,径直个位数计划即可,结果的031839就独立计划,不放在内里(其余更好的本领还不知晓ㄒoㄒ)

分享到 :
相关推荐

Leave a Reply

Your email address will not be published. Required fields are marked *