Python程序可打印今天的年,月和日
In the below example – we are implementing a python program to print the current/ today's year, month and year.
在下面的示例中-我們正在實現(xiàn)一個python程序來打印當(dāng)前/今天的年,月和年 。
Steps:
腳步:
Import the date class from datetime module
從datetime模塊導(dǎo)入日期類
Create a date object of today's date – call the today() function of date class to get the current date.
創(chuàng)建今天日期的日期對象–調(diào)用date類的today()函數(shù)以獲取當(dāng)前日期。
By using the date object – we can extract and print today's year, month and day.
通過使用日期對象,我們可以提取和打印今天的年,月和日。
Output
輸出量
Current date: 2020-03-09 Current year: 2020 Current month: 3 Current day: 9翻譯自: https://www.includehelp.com/python/program-to-print-todays-year-month-and-day.aspx
總結(jié)
以上是生活随笔為你收集整理的Python程序可打印今天的年,月和日的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 归来的福丹芝剧情介绍
- 下一篇: python调用带参函数_Python