Nov-09-2018, 10:28 AM
Hi everyone,
I'm new in scripting with python (in general too). I need some help to get a block text in a file.
This is my code :
The file to check my code
https://ufile.io/4eiaa
I'm new in scripting with python (in general too). I need some help to get a block text in a file.
This is my code :
stop = "end" last_line = 0 searchtxtDetected = False with open("20181107-115829-192.168.220.201.txt", 'r') as file: for txt in file: if 'show running-config' in txt: searchtxtDetected = True continue if searchtxtDetected: print (txt) #last_line += 1 if txt == stop: breakNevertheless, the code start when show running-config is parse but dont stop when it match my variable and print the entire file end !
The file to check my code
https://ufile.io/4eiaa