I still cant figured out how to slicing a 'string' and then grab the whole line after finding some 'string'. this is what i do so far :
content.txt :
#Try to grab this line start
#Try to grab this line 1
#Try to grab this line 2
#Try to grab this line 3
#Try to grab this line 4
#Try to grab this line 5
#Try to grab this line 6
#Try to grab this line end
#Try to grab this line 7
#Try to grab this line 8
my script:
f_name = open('D:\PROJECT\Python\content.txt', "r").read()
start = f_name.find('start')
end = f_name.find('end')
jos = slice(start, end)
make = open('D:\PROJECT\Python\result.txt', "w")
make.write(f_name[jos])
output result.txt :
start
#Try to grab this line 1
#Try to grab this line 2
#Try to grab this line 3
#Try to grab this line 4
#Try to grab this line 5
#Try to grab this line 6
#Try to grab this line
the output that i need is :
#Try to grab this line start
#Try to grab this line 1
#Try to grab this line 2
#Try to grab this line 3
#Try to grab this line 4
#Try to grab this line 5
#Try to grab this line 6
#Try to grab this line end
thanks before, i hope my explanation was clearly Any help would be greatly appreciated!