name = ''
code = ''
location1 = ''
location2 = ''
status1 = ''
status2 = ''
date = ''
time = ''
downtime = ''
day = ''
hour =''
minute = ''
# Объявление границ
downtime_border1 = ''
downtime_border2 = ''
full_downtime = ''
def template(string):
name_border1 = 7
name_border2 = string.find(' к', name_border1)
code_border1 = string.find('д', name_border2)+2
code_border2 = string.find(' ', code_border1)
location_border11 = code_border2+1
location_border21 = string.find(' не', location_border11)
location_border22 = string.find(' вновь', location_border11)
status_border11 = location_border21+1
status_border12 = location_border22+1
status_border2 = string.find(' с ')
date_border1 = status_border2+3
date_border2 = string.find(' ', date_border1)
time_border1 = date_border2+1
time_border2 = string.find(' МСК', time_border1)
# Присваивание значения 1 границе
downtime_border1 = string.find('дн', time_border2)-2
# 2 границе
downtime_border2 = string.rfind('.', downtime_border1)
name = string[name_border1:name_border2]
code = string[code_border1:code_border2]
location1 = string[location_border11:location_border21]
location2 = string[location_border11:location_border22]
status1 = string[status_border11:status_border2]
status2 = string[status_border12:status_border2]
def losed(string):
day_border1 = string.rfind('л')+2
day_border2 = string.find(' дн', day_border1)
hour_border1 = day_border2+2
hour_border2 = string.find(',', hour_border1)
minute_border1 = hour_border2+2
minute_border2 = len(string)-1
# В full_downtime вылезает Traceback
# Имя ошибки TypeError: slice indices must be integers or None or have an __index__ method
full_downtime = string[downtime_border1:downtime_border2]
day = string[day_border1:day_border2]
hour = string[hour_border1:hour_border2]
minute = string[minute_border1:minute_border2]
File "/home/gidromet_user/Документы/Pyhandler/Template.py", line 51, in losed
full_downtime = string[downtime_border1:downtime_border2]
TypeError: slice indices must be integers or None or have an __index__ method
downtime_border1 = '' # строка!
downtime_border2 = '' # строка!
# Присваивание значения 1 границе
downtime_border1 = string.find('дн', time_border2)-2
# 2 границе
downtime_border2 = string.rfind('.', downtime_border1)
TypeError: slice indices must be integers or None or have an __index__ method
full_downtime = string[downtime_border1:downtime_border2]
downtime_border1 = ''
downtime_border2 = ''