python - datetime时间输出的问题

查看:81
本文介绍了python - datetime时间输出的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

1在codecademy上学习PYTHON基础知识 学到 datetime

运行了一下代码:

from datetime import datetime
now=datetime.now()
#print now
print now.year
print now.month
print now.day
print now.time```

输出的问题是:  年 月 日 都没问题 就是 时间那里 不知道是啥意思。

'''2017
5
15
<built-in method time of datetime.datetime object at 0x7f7bd75f7f30>
None

解决方案

from datetime import datetime
now=datetime.now()
#print now
print now.year
print now.month
print now.day
print now.hour
print now.minute
print now.second
print now.microsecond

没有time属性

print now.date()
print now.time()
print now.timetuple()
print now.ctime()

这篇关于python - datetime时间输出的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆