admin 发表于 2022-3-24 16:29:15

在 Python 中获取当前日期和时间

Always gives me perfect date.

Sample Output

Current Day is: 1
Current Month is: 2
Current Year is: 2020
Current Hour is: 17
Current Minute is: 3
Current Second is: 8
Current Microsecond is: 556483
from datetime import datetime

now = datetime.now()
print("Current Day is:", now.day)
print("Current Month is:", now.month)
print("Current Year is:", now.year)
print("Current Hour is:", now.hour)
print("Current Minute is:", now.minute)
print("Current Second is:", now.second)
print("Current Microsecond is:", now.microsecond)
页: [1]
查看完整版本: 在 Python 中获取当前日期和时间