标签:ros repr inf ted cells com one mkt ber
time模块是包含各方面对时间操作的函数. 尽管这些常常有效但不是所有方法在任意平台中有效。
时间相关的操作,时间有三种表示方式:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import time# ========== 时间戳 ==========print time.time() print time.mktime(time.localtime()) # ========== 元组形式 ==========print time.gmtime() #可加时间戳参数print time.localtime() #可加时间戳参数print time.strptime(‘2014-11-11‘, ‘%Y-%m-%d‘) # ========== 字符串形式 ==========print time.strftime(‘%Y-%m-%d‘) #默认当前时间print time.strftime(‘%Y-%m-%d‘,time.localtime()) #默认当前时间print time.asctime()print time.asctime(time.localtime())print time.ctime(time.time())"""格式化占位符: %Y Year with century as a decimal number. %m Month as a decimal number [01,12]. %d Day of the month as a decimal number [01,31]. %H Hour (24-hour clock) as a decimal number [00,23]. %M Minute as a decimal number [00,59]. %S Second as a decimal number [00,61]. %z Time zone offset from UTC. %a Locale‘s abbreviated weekday name. %A Locale‘s full weekday name. %b Locale‘s abbreviated month name. %B Locale‘s full month name. %c Locale‘s appropriate date and time representation. %I Hour (12-hour clock) as a decimal number [01,12]. %p Locale‘s equivalent of either AM or PM.""" |

datetime模块提供对于日期和时间进行简单或复杂的操作. datetime 模块提供了一下的可用类型(Available Types)。
|
1
2
3
4
|
# 时间相减import datetimeprint datetime.datetime.now()print datetime.datetime.now() - datetime.timedelta(days=5) |
标签:ros repr inf ted cells com one mkt ber
原文地址:https://www.cnblogs.com/my-blogs-for-everone/p/8890948.html