Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: filter_lines.py
- # Author: Jeoi Reqi
- # This script reads lines from the input file, filters out lines starting with a custom filter & writes the remaining lines to the output file.
- # Function to define the filter
- def filter_lines(input_file, output_file):
- with open(input_file, 'r', encoding='utf-8') as infile, open(output_file, 'w', encoding='utf-8') as outfile:
- for line in infile:
- # Check if the line starts with "渝ICP备"
- if not line.startswith("渝ICP备"): # Edit this to match your filter goals
- outfile.write(line)
- # Replace 'input.txt' with the name of your input file and 'output.txt' with the desired output file name
- input_file_name = 'input.txt' # Replace 'input.txt' with the name of your input file
- output_file_name = 'output.txt' # Replace 'output.txt' with the name of your output file
- filter_lines(input_file_name, output_file_name)
- print(f"Filtered lines starting with '渝ICP备' from {input_file_name} and saved the result in {output_file_name}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement