예제
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()
시험
심화