def count_down(time): hour=minute=second=0 if '小时'in time: h=time[:time.index('小时')] time=time[time.index('小时')+4:] hour=digits_only(h) if hour == '': hour=shu2num(h) if hour==0.5: minute=30 else: hour=int(hour) if '分'in time: m=time[:time.index('分')] time=time[time.index('分')+2:] minute=digits_only(m) if minute == '': minute=shu2num(m) if minute==0.5: second=30 else: minute=int(minute) if '秒'in time: s=time[:time.index('秒')] second=digits_only(s) if second == '': second=shu2num(s) if second==0.5: second=1 else: second=int(second) return (hour,minute,second)
def exact_time(when): if ':' in when: _when=digits_only(when[:when.index(':')]) when_=digits_only(when[when.index(':')+1:]) if int(when_)>=60: _when=int(_when)+int(when_)/60 when_=int(when_)%60 if int(_when)>=24: exact_when='00:00' else: exact_when=str(_when)+':'+str(when_) elif ':' in when: _when=digits_only(when[:when.index(':')]) when_=digits_only(when[when.index(':')+1:]) exact_when=_when+':'+when_ elif '点半' in when: if not digits_only(when[:when.index('点半')]): _when=str(shu2num(when[:when.index('点半')])) else: _when=digits_only(when[:when.index('点半')]) exact_when=_when+':30' elif '点一刻' in when: if not digits_only(when[:when.index('点一刻')]): _when=str(shu2num(when[:when.index('点一刻')])) else: _when=digits_only(when[:when.index('点一刻')]) exact_when=_when+':15' elif '点三刻' in when: if not digits_only(when[:when.index('点三刻')]): _when=str(shu2num(when[:when.index('点三刻')])) else: _when=digits_only(when[:when.index('点三刻')]) exact_when=_when+':45' elif '点' in when: if not digits_only(when[:when.index('点')]): _when=str(shu2num(when[:when.index('点')])) else: _when=digits_only(when[:when.index('点')]) if not when[when.index('点')+2:]: when_='00' else: if not digits_only(when[when.index('点')+2:]): when_=str(shu2num(when[when.index('点')+2:])) else: when_=digits_only(when[when.index('点')+2:]) if int(when_)>=60: _when=int(_when)+int(when_)/60 when_=int(when_)%60 if int(_when)>=24: exact_when='00:00' else: exact_when=str(_when)+':'+str(when_) else: exact_when='00:00' return exact_when