datetime函数:
vi a1.py
#!/usr/bin/python
import datetime
now=datetime.datetime.now()
today=datetime.date.today()
yesterday=datetime.date.today() - datetime.timedelta(days=1)
print now
print today
print yesterday
:wq
python a1.py
转载于:https://blog.51cto.com/yangzhiming/2130651