jfz-2023-s473579/TaskD01/run.py

21 lines
676 B
Python
Raw Normal View History

2023-11-27 12:47:50 +01:00
import re
import sys
def write_answer(row, ouput_file):
with open(ouput_file, "a", encoding="utf-8") as file:
file.write(row)
2023-11-27 22:38:20 +01:00
def main_function(pattern, input_file, output_file):
2023-11-27 12:47:50 +01:00
with open(output_file, "w", encoding="utf-8") as output_file1:
with open(input_file, "r", encoding="utf-8") as file:
for row in file:
help_row = row.strip()
if re.search(pattern, help_row):
write_answer(row, output_file)
2023-11-27 22:38:20 +01:00
pattern = re.compile(r'Hamlet')
2023-11-27 12:47:50 +01:00
# output_file ='simple.out'
# input_file = 'simple.in'
input_file = sys.argv[1]
output_file = sys.argv[2]
2023-11-27 22:38:20 +01:00
main_function(pattern, input_file, output_file)