python 计算校历,根据日期判断当前时第几周
打算做个校历查询功能,研究了一下校历格式。感觉查表时最方便的,不过表格存储即占空间又不利于维护。因此想通过程序实现一下。下面startDateStr是起始计算周,按照校历规范基本为星期一,searchDateStr你要查询的日期。
不知道下面代码是否正确
import datetime
startDateStr='2015-9-7'
searchDateStr='2015-10-27'
def getZhouForXL(startDateStr,searchDateStr):
try:
startDate=datetime.datetime.strptime(startDateStr,'%Y-%m-%d')
searchDate=datetime.datetime.strptime(searchDateStr,'%Y-%m-%d')
zhouNum=int(searchDate.strftime('%W'))-int(startDate.strftime('%W'))+1
return 1,'',zhouNum
except Exception,ex:
print Exception,':',ex
return 0,ex,0
test code
getZhouForXL(startDateStr,searchDateStr)
getZhouForXL('asd',searchDateStr)
相关阅读:
如何把4-6行添加1-3行结尾
pyspider 抓取https网站获取不到本地证书 怎么解决?
alert弹出框的问题
fetch跨域请求接口then()返回的response.body为null
编译安装的nginx如何卸载?
comtypes库运行报错,无法传送VARIANT类型的参数
MySQL报这个错误,是哪里错了呢?[Err] 1064 - You have an error .....
GUI实现的原理有相关的资料吗
thinkphp 好像不支持动态Include 文件?
手机端用rem单位默认字体设置为多大?有什么好的css手机端框架?
THinkPHP开发微信支付,如何配置微信支付授权目录?
移动端点击事件失效
GIT远程同步的问题
汇编单步执行时发现了一个 call .+914
PHP使用phpmailer发送邮件?
ThinkPHP重写模式下URL大小写问题
vm虚拟机装的centos搭建邮件服务器 给qq邮箱发邮件出现报错
Go如何通用的处理请求回来的json数据?
nodejs微信开发 40016错误
ajax Authorization 鉴权失败