예제

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/8d7b3452-7f6a-410b-98d6-bbcdcb104da4/Untitled.png

data = []

fpw = open("data.txt", "w")
while True:
    name = input("name : ")
    age = int(input("age : "))
    cont = input("continue?(y/n)")
    data.append({'name': name, 'age': age})
    fpw.write('%s,%s\\n'%(name, age))
    if cont == 'n':
        fpw.close()
        break

fpr = open("data.txt", "r")
print('-' * 30)
print('name', ' ' * 10, 'age', ' ' * 10)
for n in fpr:
    n = n.split(',')
    print('%s              %s'%(n[0],n[1]))
fpr.close()

시험

심화

lesson.pdf