Найти - Пользователи
Полная версия: Unhandled Exception: ZeroDivisionError('float division',)
Начало » Python для новичков » Unhandled Exception: ZeroDivisionError('float division',)
1
iga
Помогите исправить код. Работает если задаешь небольшую входящую переменную 15, и не работает если например 20 и выше - вылетает с ошибкой

Unhandled Exception: ZeroDivisionError('float division',)
import time, datetime, calendar

def ttimes(d):
currentdate = datetime.datetime.utcnow() #now
currentdate = str(currentdate.replace(hour=00, minute=00, second=01, microsecond=00)) #zero out day
st = int(calendar.timegm(time.strptime(currentdate, '%Y-%m-%d %H:%M:%S'))) #Now
t = int(calendar.timegm(time.strptime(currentdate, '%Y-%m-%d %H:%M:%S')) - d * 24 * 3600) #minus d days
interv = 1 * 24 * 3600
result = []
#date = t
while t != st :
date = t
print date
t += interv
print t
result.append({'time': int(t) * 1000,'value': int(s_db(date,t))})
return json.dumps(result)
Пишу пару месяцев на питоне, поэтому как получается:)
doza_and
это у вас наверное в
result.append({'time': int(t) * 1000,'value': int(s_db(date,t))})
у меня без этой строчки проходит
s_db - что такое - непонятно- вы ее не привели
iga
Да,да. именно там и было деление на ноль в выборке из БД. Спасибо.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB