Python获取当前时间之前的1分钟,5分钟,15分钟的时间
import datetime one_minute_ago = datetime.datetime.now() - datetime.timedelta(minutes=1) five_minutes_ago = datetime.datetime.now() - datetime.timedelta(minutes=5) fifteen_minutes_ago = datetime.datetime.now() - datetime.timedelta(minutes=15) print(one_minute_ago) print(five_minutes_ago) print(fifteen_minutes_ago)