第9天,python之路

给自己放了几天假,过了过中秋。可以收心了,继续我的是事情,到我喜欢的地方了,常用的模块

  •  时间模块time和datetime
所有的时间开始于:纪元时间1970年,也叫时间戳timestamp

time.time()  #当前时间戳

time.strftime('%Y-%M-%D %X)  #格式化的字符串时间

 格式化字符串的时间格式:

 1 %a    Locale’s abbreviated weekday name.     
 2 %A    Locale’s full weekday name.     
 3 %b    Locale’s abbreviated month name.     
 4 %B    Locale’s full month name.     
 5 %c    Locale’s appropriate date and time representation.     
 6 %d    Day of the month as a decimal number [01,31].     
 7 %H    Hour (24-hour clock) as a decimal number [00,23].     
 8 %I    Hour (12-hour clock) as a decimal number [01,12].     
 9 %j    Day of the year as a decimal number [001,366].     
10 %m    Month as a decimal number [01,12].     
11 %M    Minute as a decimal number [00,59].     
12 %p    Locale’s equivalent of either AM or PM.    (1)
13 %S    Second as a decimal number [00,61].    (2)
14 %U    Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.    (3)
15 %w    Weekday as a decimal number [0(Sunday),6].     
16 %W    Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.    (3)
17 %x    Locale’s appropriate date representation.     
18 %X    Locale’s appropriate time representation.     
19 %y    Year without century as a decimal number [00,99].     
20 %Y    Year with century as a decimal number.     
21 %z    Time zone offset indicating a positive or negative time difference from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal hour digits and M represents decimal minute digits [-23:59, +23:59].     
22 %Z    Time zone name (no characters if no time zone exists).     
23 %%    A literal '%' character.

time.ctime(time.time())  #'Fri Sep 28 17:51:22 2018'        相当于    time.asctime()    #时间显示

日期:datetime.datetime.now()

   datetime.date.fromtimestamp(time.time())

 

转载于:https://www.cnblogs.com/haccer/articles/9715591.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值