100-016

输出指定格式的日期。
方法一:
 1 #! /usr/bin/env python
 2 # -*- coding:utf-8 -*-
 3 # 输出指定格式的日期。
 4 
 5 import time
 6 
 7 print (time.time() )
 8 #1498539133.655
 9 print (time.localtime() )
10 #tm_year=2017, tm_mon=6, tm_mday=27, tm_hour=12, tm_min=53, tm_sec=16, tm_wday=1, tm_yday=178, tm_isdst=0
11 print (time.asctime() )
12 #'Tue Jun 27 12:53:50 2017'
13 print (time.strftime('%Y-%m-%d %H:%M:%S',time.localtime()) )
14 #'2017-06-27 13:00:57'
15 
16 import datetime
17 
18 print (datetime.date.today() )
19 #datetime.date(2017, 6, 27)
20 print (datetime.date.today().strftime('%d/%m/%Y') )
21 #'27/06/2017'
22 print (datetime.date(1941, 1, 5) )
23 #datetime.date(1941, 1, 5)

 

posted @ 2018-04-10 06:38  睡到自然醒的猪  阅读(77)  评论(0)    收藏  举报

iaoexl at outlook dot com, 返回顶部 →友情链接: 信息港 同城信息