import datetime
print("獲取當前時間和日期:",datetime.datetime.now())
UtcNow = datetime.datetime.utcnow()
print("獲取當前時間和日期的世界標準時間:",UtcNow)
print("獲取日期:",UtcNow.date())
print("獲取年:",UtcNow.year)
print("獲取月:",UtcNow.month)
print("獲取日:",UtcNow.day)
print("獲取時:",UtcNow.time())
print("獲取星期:",UtcNow.isoweekday())
print(f"轉換的類型:{type(UtcNow.isoformat())}",UtcNow.isoformat())
print("轉換格式之後:",UtcNow.strftime('%Y/%m/%d'))
print("结构化日期,返回日期时间元组:",UtcNow.timetuple())
print("返回公历序数(公元0年開始算):",UtcNow.toordinal())
标签:獲取,Python,datetime,日期,UtcNow,時間,print
From: https://blog.csdn.net/weixin_45078841/article/details/137051841