使用Python,以整数形式获取当月的日期 [英] Using Python, get the day of the current month as an integer
本文介绍了使用Python,以整数形式获取当月的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要编写一个以整数形式返回月份中的某天的方法.例如,如果是2011年2月8日,我想使用这样的方法:
I need to write a method that returns the day of the month as an integer. For example, if it's Feb 8th 2011, I want to have method like this:
>>> day = get_day_of_month()
一天将被赋予整数8
推荐答案
>>> import datetime
>>> datetime.datetime.today().day
这篇关于使用Python,以整数形式获取当月的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文