网络编程
位置:首页>> 网络编程>> Python编程>> python 输出上个月的月末日期实例

python 输出上个月的月末日期实例

作者:luoganttcc  发布时间:2022-11-30 16:33:11 

标签:python,日期,上个月,月末

如下所示:


import dateutil
def before_month_lastday(ti):
 today=dateutil.parser.parse(str(ti))
 first = datetime.date(day=1, month=today.month, year=today.year)
 lastMonth = first - datetime.timedelta(days=1)
 cc=str(lastMonth.year)+str(lastMonth.month)+str(lastMonth.day)
 return int(cc)
print(before_month_lastday(20171011))

2017930

来源:https://blog.csdn.net/luoganttcc/article/details/78647518

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com