python 获取年月日

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

示例

ubuntu@ThinkCentre:~$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

import datetime
datetime.datetime.now().year
2017
datetime.datetime.now().month
3
datetime.datetime.now().day
23

你可能感兴趣的:(python 获取年月日)