描述
方法localtime()類似於 gmtime() 但它將秒數轉換為本地時間。如果未提供 secs 或 None,則使用 time() 返回的當前時間。當 DST 適用於給定時間時,dst 標誌設置為 1。
用法
以下是語法localtime()方法≫
time.localtime([ sec ])
參數
sec─這些是要轉換為結構 struct_time 表示的秒數。
返回值
此方法不返回任何值。
示例
下麵的例子展示了 localtime() 方法的用法。
#!/usr/bin/python3
import time
print ("time.localtime():%s" , time.localtime())
結果
當我們運行上麵的程序時,它會產生以下結果:
time.localtime():time.struct_time(tm_year = 2016, tm_mon = 2, tm_mday = 15, tm_hour = 10, tm_min = 13, tm_sec = 50, tm_wday = 0, tm_yday = 46, tm_isdst = 0)
相關用法
- Python 3 time strftime()用法及代碼示例
- Python 3 time time()用法及代碼示例
- Python 3 time asctime()用法及代碼示例
- Python 3 time altzone()用法及代碼示例
- Python 3 time mktime()用法及代碼示例
- Python 3 time gmtime()用法及代碼示例
- Python 3 time sleep()用法及代碼示例
- Python 3 time ctime()用法及代碼示例
- Python 3 time tzset()用法及代碼示例
- Python 3 time strptime()用法及代碼示例
- Python 3 time clock()用法及代碼示例
- Python 3 Number tan()用法及代碼示例
- Python 3 os.fstatvfs()用法及代碼示例
- Python 3 List pop()用法及代碼示例
- Python 3 os.minor()用法及代碼示例
- Python 3 dictionary cmp()用法及代碼示例
- Python 3 String isupper()用法及代碼示例
- Python 3 os.close()用法及代碼示例
- Python 3 List index()用法及代碼示例
- Python 3 String decode()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - time localtime() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。