亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在使用relativedelta時將月份轉換為幾天?

如何在使用relativedelta時將月份轉換為幾天?

料青山看我應如是 2021-03-20 10:23:16
這是我的方法def get_remaining_days_in_financial_month(self, from_day):    current_financial_day = date(from_day.year, from_day.month,                                 self.financial_day_of_month)    end_financial_month = current_financial_day + relativedelta(months=+1)    delta = relativedelta(end_financial_month, from_day)    remaining_days_in_financial_month = delta.days    return remaining_days_in_financial_month當我調試時,我看到current_financial_day = 2013-06-01delta = relativedelta(months=+1)end_financial_month = 2013-07-01from_day = 2013-06-01remaining_days_in_financial_month = 0盡管此信息是正確的,但我想知道的數量days,因為從282月到306月和318月的天數發生了變化我怎樣才能做到這一點?該dateutil庫不提供一種方式,似乎
查看完整描述

2 回答

?
慕少森

TA貢獻2019條經驗 獲得超9個贊

使用datetime.timedelta(); 只需減去兩個日期:


delta = end_financial_month - from_day

return delta.days


查看完整回答
反對 回復 2021-03-31
  • 2 回答
  • 0 關注
  • 195 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號