#Python綜合範例13 while info != “” 便一直readline(),Page 9-39
infile = open(“student.dat”,”r”,encoding=”utf-8″)
info = infile.readline()
while info != “”:
lst = info.split()
cal = eval(lst[1])
acc = eval(lst[2])
avg = cal*0.6 + acc*0.4
print(“|%10s: %.2f|” %(lst[0],avg))
info = infile.readline()
infile.close()
“””
.dat檔內容如:
Peter 11 22
Mary 33 44
John 55 66
“””
#綜合範例14,微積分最高分
近期留言