Python获取当前年月日

2023-01-31 05:01:56 python 获取 年月日

import datetime
datetime.datetime.now().year
datetime.datetime.now().month
datetime.datetime.now().day

[root@skyeye ~]# python 
Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more infORMation.
>>> import datetime
>>> datetime.datetime.now().year
2018
>>> datetime.datetime.now().month
11
>>> datetime.datetime.now().day
14

 

相关文章