1 Star 0 Fork 0

dzc/Python-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
days_from_date.py 695 Bytes
一键复制 编辑 原始数据 按行查看 历史
Sai Lakshmi 提交于 2019-10-01 23:35 +08:00 . program to find days from given date
from datetime import date
import sys
import re
import calendar
def cleanDate(date_):
date_.replace(' ','')
date_.replace(',','')
date_.replace('/','')
return date_
def getYearMonthDay(date_):
day , year = map(int,re.findall(r'\d+',date_))
month = ''.join(re.findall(r'[a-zA-Z]',date_)).capitalize()
month_num = list(calendar.month_abbr).index(month[:3])
return year,month_num,day
def numOfDays(year,month_num,day):
days = date(year,month_num,day).timetuple()[-2]
return days
date_ = sys.argv[1]
date_ = cleanDate(date_)
year,month_num,day = getYearMonthDay(date_)
print(numOfDays(year,month_num,day) - 1)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sdredboy/Python-1.git
git@gitee.com:sdredboy/Python-1.git
sdredboy
Python-1
Python-1
master

搜索帮助