This commit is contained in:
Pawel Felcyn 2023-12-11 14:23:02 +01:00
parent e1be7d9d73
commit c40716abe8
3 changed files with 21 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import re
import os
def find_hamlet_lines(file_path):
with open(file_path, 'r') as file:
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
hamlet_lines = []

View File

@ -2,7 +2,7 @@ import re
import os
def find_pies_lines(file_path):
with open(file_path, 'r') as file:
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
pies_lines = []

19
TaskD03/run.py Normal file
View File

@ -0,0 +1,19 @@
import re
import os
def find_date_lines(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
pies_lines = []
pattern = re.compile(r'19[0-9][0-9] r\.')
for _, line in enumerate(lines, start=1):
if re.search(pattern, line):
pies_lines.append(line)
return pies_lines
path = os.path.join(os.path.dirname(__file__), 'simple.in')
lines = find_date_lines(path)
print(lines)