jfz-2023-s473579/TaskE02/run.py

22 lines
625 B
Python

import sys
import re
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
# input_file = 'test.in'
# output_file = 'test.out'
input_file = sys.argv[1]
output_file = sys.argv[2]
pattern = re.compile(r'^\d{2}-\d{3}')
pattern2 = re.compile(r'^(\d{2})')
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
if pattern.match(row_input_file):
write_answer(pattern2.match(row_input_file).group(1))
else:
write_answer('<NONE>')