3.10 datetime

datetime

import datetime
# from datetime import datetime 方法不同
time_now = datetime.datetime.now()
print(time_now)
print(str(time_now)[:19],type(time_now))
print(datetime.datetime.now()+datetime.timedelta(weeks=3))
print(datetime.datetime.now()+datetime.timedelta(weeks=-4))
print(datetime.datetime.now()+datetime.timedelta(days=15))
输出结果:
2019-06-28 19:39:06.398054
2019-06-28 19:39:06 <class 'datetime.datetime'>
2019-07-19 19:39:06.398054
2019-05-31 19:39:06.398054
2019-07-13 19:39:06.398054
```

```python
current_time =datetime.datetime.now()此时此刻的时间
print(current_time.replace(year=1979))
print(current_time.replace(year=2010,month=3,day=25))
print(datetime.date.fromtimestamp(3829382989))
输出结果:
1979-06-28 19:45:40.741369
2010-03-25 19:45:40.741369
2091-05-07
``````

 

posted @ 2019-07-15 22:09  God_with_us  阅读(120)  评论(0编辑  收藏  举报