當(dāng)前位置:首頁 > IT技術(shù) > 編程語言 > 正文

Python三種方法讓你快速找到時(shí)間
2022-03-06 18:00:04

用time模塊獲取時(shí)間

import time
print(time.time())
1586813438.419919
print(time.ctime())
Mon Apr 13 23:30:38 2020

用datetime模塊獲取時(shí)間

import datetime
print(datetime.datetime.now())
2021-11-13 23:30:38.419951
print(datetime.date.today())
2021-11-13

用os模塊獲取時(shí)間

import os
os.system('date')
Sun Feb 20 10:12:36 UTC 2022
os.system('date +"%Y-%m-%d %H:%M:%S"')
2022-02-20 10:30:09

3 ways to get the current time in python
10 tips to use Python OS module

本文摘自 :https://blog.51cto.com/u

開通會(huì)員,享受整站包年服務(wù)立即開通 >