python 时间datetime

from datetime import datetime

# now=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# print(now)
# dc = datetime.strptime(now,"%Y-%m-%d %H:%M:%S")


now=datetime.now().isoformat()
print(now)

t1=datetime.fromisoformat('2019-11-11T00:52:43+00:00')
print(t1)

t2=datetime.strptime("2008-09-03T20:56:35.450686Z", "%Y-%m-%dT%H:%M:%S.%fZ")
print(t2)

t3=datetime.strptime("2021-08-06T00:30:00.000+0000", "%Y-%m-%dT%H:%M:%S.%f%z")
print(t3)


            # 记录离最近使用时间最远的
            last=datetime.strptime(self.ips[i]['last'],"%Y-%m-%d %H:%M:%S")
            if (now-last).seconds > max_seconds:
                max_seconds=(now-last).seconds
                maxid=i
原文地址:https://www.cnblogs.com/yansc/p/15107028.html