[英]Timestamp in python (year,month,day,hour,minute)
Currently im using目前我正在使用
datetime.now()
The result im getting is for example我得到的结果是例如
datetime.datetime(2020, 2, 4, 10, 14, 20, 768814)
My goal is to get我的目标是得到
datetime.datetime(2020, 2, 4, 10, 14, 20)
You can use datetime.replace()
:您可以使用
datetime.replace()
:
>>> datetime.now().replace(microsecond=0)
datetime.datetime(2020, 2, 4, 9, 24, 32)
Its simple.这很简单。 If you don't want the microseconds, use below:
如果您不想要微秒,请使用以下内容:
datetime.now().replace(microsecond=0)
Output ---> datetime.datetime(2020, 2, 4, 14, 53, 44)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.