描述
Pythom時間法asctime()將表示由 gmtime() 或 localtime() 返回的時間的元組或 struct_time 轉換為以下形式的 24 個字符的字符串:'Tue Feb 17 23:21:05 2009'。
用法
以下是語法asctime()方法 -
time.asctime([t]))
參數
t- 這是一個由 9 個元素或 struct_time 組成的元組,表示 gmtime() 或 localtime() 函數返回的時間。
返回值
此方法返回以下形式的 24 個字符的字符串:'Tue Feb 17 23:21:05 2009'。
示例
下麵的例子展示了 asctime() 方法的用法。
#!/usr/bin/python
import time
t = time.localtime()
print "time.asctime(t):%s " % time.asctime(t)
當我們運行上麵的程序時,它會產生以下結果 -
time.asctime(t):Tue Feb 17 09:42:58 2009
相關用法
- Python time altzone()用法及代碼示例
- Python time ctime()用法及代碼示例
- Python time mktime()用法及代碼示例
- Python time localtime()用法及代碼示例
- Python time sleep()用法及代碼示例
- Python time strftime()用法及代碼示例
- Python time clock()用法及代碼示例
- Python time tzset()用法及代碼示例
- Python time time()用法及代碼示例
- Python time replace()用法及代碼示例
- Python time gmtime()用法及代碼示例
- Python time strptime()用法及代碼示例
- Python time.monotonic()用法及代碼示例
- Python time.asctime()用法及代碼示例
- Python time.ctime()用法及代碼示例
- Python time.perf_counter()用法及代碼示例
- Python time.get_clock_info()用法及代碼示例
- Python time.gmtime()用法及代碼示例
- Python time.time()用法及代碼示例
- Python time.mktime()用法及代碼示例
注:本文由純淨天空篩選整理自 Python time asctime() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。