9,10,11,12,1 第一学期
2,3,4,5,6,7 第二学期其中8月份放假,暂且放入第一学期。因为大部分学校都选在8月底开学
import datetimedef getXNandXQ(): now=datetime.datetime.now() year=int(now.strftime("%Y")) month=int(now.strftime("%m")) if month>=2 and month<8: xn="%d-%d"%(year-1,year) xq=2 elif month>=8: xn="%d-%d"%(year,year+1) xq=1 else: xn="%d-%d"%(year-1,year) xq=1 return xn,xqdef getXNandXQByYM(year,month): if month>=2 and month<8: xn="%d-%d"%(year-1,year) xq=2 elif month>=8: xn="%d-%d"%(year,year+1) xq=1 else: xn="%d-%d"%(year-1,year) xq=1 return xn,xq