鏃堕棿time妯″潡
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鏃堕棿time妯″潡相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e4%b8%8d%e5%90%8c%e7%9a%84' title='涓嶅悓鐨?>涓嶅悓鐨?/a> strftime time() sds 鍏ラ棬 roc process str
time妯″潡锛?/p>
import time --鏃堕棿妯″潡 --time 锛?涓夌涓嶅悓鐨勬椂闂存牸寮?鍙互鐩镐簰杞崲
鏃堕棿鎴?timestamp):
--浠?970骞?鏈?鏃?0:00:00寮€濮嬫寜绉掕绠楃殑鍋忕Щ閲?/p>
time_stamp = time.time() print(time_stamp)
鏍煎紡鍖栨椂闂?format string)锛?/p>
--鏅€氱殑瀛楃涓叉牸寮忕殑鏃堕棿
format_time = time.strftime("%Y-%m-%d %X") print(format_time)
缁撴瀯鍖栨椂闂?struct time)锛?/p>
--struct_time鍏冪粍鍏辨湁9涓厓绱犲叡涔濅釜鍏冪礌锛屽垎鍒负(骞达紝鏈堬紝鏃ワ紝鏃讹紝鍒嗭紝绉掞紝涓€骞翠腑绗嚑鍛紝涓€骞翠腑绗嚑澶╋紝澶忎护鏃?
# print(format(time.localtime())) print(format(time.gmtime())) 鏈湴鏃跺尯鐨剆truct_time: time.struct_time(tm_year=2019, tm_mon=3, tm_mday=7, tm_hour=16, tm_min=22, tm_sec=11, tm_wday=3, tm_yday=66, tm_isdst=0) UTC鏃跺尯鐨剆truct_time: time.struct_time(tm_year=2019, tm_mon=3, tm_mday=7, tm_hour=8, tm_min=22, tm_sec=11, tm_wday=3, tm_yday=66, tm_isdst=0)
print(time.localtime(0)) --1970,1,1,8:00 print(time.localtime(360*24*365)) --1971,1,1,8:00
缁撴瀯鍖栨椂闂?鏍煎紡鍖栨椂闂?鏃堕棿鎴充笁鑰呬箣闂磋繘琛岃浆鎹?
# 鎺ㄨ繜鎸囧畾鐨勬椂闂磋繍琛岋紝鍗曚綅涓虹 start = time.time() time.sleep(3) end = time.time() print(end-start)
datetime妯″潡node js 鑾峰彇绋嬪簭鎵ц鏃堕棿 time timeEnd