Uke 3 #1 utkast
This commit is contained in:
parent
d48d576891
commit
27b4466948
43
uke3.py
Normal file
43
uke3.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Thu Sep 28 08:23:56 2023
|
||||
|
||||
@author: innagumauri
|
||||
"""
|
||||
|
||||
#%% Task 1
|
||||
|
||||
import re
|
||||
|
||||
def student_information(filename):
|
||||
with open(filename, 'r', newline='', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
stud=[]
|
||||
for line in lines:
|
||||
if "#" in line:
|
||||
continue
|
||||
d=re.findall(r"[^, :\n]+", line)
|
||||
stud.append({"name":d[0], "age":d[1], "phone number":d[2]})
|
||||
return stud
|
||||
|
||||
print(student_information("data.txt"))
|
||||
|
||||
|
||||
#%% Task 2
|
||||
|
||||
|
||||
|
||||
import re
|
||||
import pathlib import path
|
||||
|
||||
def get_imp_file(file):
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
#lines = f.readlines()
|
||||
imp=re.findall(r"import\s(\w+)", f.read())
|
||||
return imp
|
||||
|
||||
def get_imp_dir(dir="./"):
|
||||
|
||||
|
||||
get_imp_file("exercises2.py")
|
Loading…
Reference in New Issue
Block a user