Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- first_marker = '# Vlan'
- second_marker = '# '
- with open(r"C:\123\des.cfg", "r") as source:
- n = 0
- for line in source:
- n += 1
- if first_marker in line:
- n_first_m = n - 1
- source.close()
- source_2 = ''
- for linenum,line in enumerate(open(r"C:\123\des.cfg", "r")):
- if linenum>n_first_m:
- split_source = line.strip()
- source_2 = source_2 + split_source + "\n"
- with open(r"C:\123\buff.cfg", "w") as f2:
- f2.write(source_2)
- f2.close()
- with open(r"C:\123\buff.cfg", "r") as source:
- nn = 0
- for line in source:
- nn += 1
- if second_marker in line:
- n_second_m = nn - 2
- break
- source.close()
- source_3 = ''
- for linenum,line in enumerate(open(r"C:\123\buff.cfg", "r")):
- if linenum<n_second_m:
- split_source = line.strip()
- source_3 = source_3 + split_source + "\n"
- with open(r"C:\123\source.cfg", "w") as f3:
- f3.write(source_3)
- f3.close()
- os.remove(r"C:\123\buff.cfg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement