date_time = datetime.datetime.now()
time = date_time.time()
# date_time is a datetime object tuple of year, month, day, hour, minnute, second, ms
# to access the time portion, simply call the time() function, which will return a tuple of only the hour, minue, second portion
# printing the time will give timestamp representation, but the object is actually of type datetime.time
datetime.time()
等同于datetime.time(hours=0, minute=0)
:^{} 是一个模块。^{} 是一个类。
datetime.time()
是使用默认的小时、分钟值(0
,0
)创建的类的实例,例如,要创建对应于19:00
的time对象,可以使用datetime.time(19, 0)
。要仅打印现有^{} 或^{} 实例的时间,可以使用^{} time format :
像这样:
相关问题 更多 >
编程相关推荐