Teile 10 bis 12.

This commit is contained in:
2023-03-28 12:26:50 +02:00
parent 298151634d
commit f7a5db9f39
27 changed files with 6459 additions and 75 deletions

29
teil10/read_csv.py Normal file
View File

@@ -0,0 +1,29 @@
school = []
class Lehrer():
def __init__(self, vorname, name):
self.vorname = vorname
self.name = name
def __str__(self):
return f'{self.vorname} {self.name}'
try:
with open('namen.csv','r') as f:
for line in f:
splitted = line.strip().split(',')
name = splitted[0]
vorname = splitted[1]
lehrer = Lehrer(vorname,name)
school.append(lehrer)
except IOError as x:
print(f'I/O-Fehler: {x}')
print(school)
print(school[0])
print(school[3])