发布时间:2019-08-29 07:39:36编辑:auto阅读(2286)
python中time.time()和 time.strftime():
time.time()返回的是一个浮点数,以秒为单位,time.strftime后可以自定义格式,如time.strftime('%Y-%m-%d %H:%M:%S')
#!/usr/bin/python
import time
t1 = time.time()
print t1
t2 = time.strftime('%Y-%m-%d %H:%M:%S')
print t2
:wq
今天、昨天、上月、去年:
#!/usr/bin/python
import time
today = time.strftime('%Y-%m-%d')
yesterday = time.localtime()[2]-1
last_month = time.localtime()[1]-1
last_year = time.localtime()[0]-1
print today
print yesterday
print last_month
print last_year
:wq
上一篇: CheungSSH python自动化运
下一篇: python3.6中安装numpy,pa
47879
46443
37333
34772
29344
26007
24960
19976
19578
18074
5821°
6448°
5962°
5987°
7093°
5937°
5977°
6471°
6435°
7817°