Greetings to all. There is a script that parses the exel list and displays the desired line for me, it works well. But how to make the script start its work again after completing its task? here is the script itself
#!/usr/bin/python3 # -*- coding: utf-8 -*- from xlrd import open_workbook from tn import * rb = open_workbook('/home/kocik/Рабочий стол/clients.xls') sheet_s = rb.sheet_by_index(0) sheet_o = rb.sheet_by_index(1) massiv=[] def value_dog(): value = int() value = input("Введите номер договора:") try: valye=int(value) dalee=pars_client(value) except: print("Вероятно ошибка, попробуйте заново") ret=value_dog() def pars_client(value): for ii in range(sheet_s.nrows):#Парсим сокол data = sheet_s.cell_value(ii,0) if int(value) == data or value == data: for i in range(sheet_s.ncols): mass=sheet_s.cell_value(ii,i) massiv.append(mass) else: continue for ii in range(sheet_o.nrows):#Парсим опытную и сырский data = sheet_o.cell_value(ii,0) if int(value) == data or value == data: for i in range(sheet_o.ncols): massa = sheet_o.cell_value(ii,i) massiv.append(massa) else: continue #print(massiv) if len(massiv)<1 : print ("Данного абонента нет в списке") ret=value_dog() else: vlan = int(massiv[1]) switch = massiv[3] port = massiv[4] print ("################################################################\n""Улица "+massiv[6]+" "+str(massiv[7])+"-"+str(massiv[8])+"\n"+"Vlan: "+str(vlan)+', '+"Подключен на: "+str(switch)+' в '+str(port)+' порт') teln = telnet_connect(vlan,switch,port) def main(): parses = value_dog() if __name__=='__main__': main() If after teln = telnet_connect (vlan, switch, port) add parses = value_dog () then it continues to work, but after entering the number it does operations on the previous input number. Where is the mistake? and how to make the program could constantly work?
value_dogfunction, in which the user enters data and calls the parser. Thereby, you will get rid of the recursive call and confusion with scopes. - mkkik