#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,微積分最高分








![Python如何寫入docx文件? from docx import Document ; doc = Document() ; table = doc.add_table(rows=5, cols=3) ; table.cell(r,c).text = str(tabs[r][c]) ; doc.add_heading ; p = doc.add_paragraph ; p.add_run ; doc.add_picture ; 使用wordPad開啟會少最後一個row,可以用免費的LibreOffice Python如何寫入docx文件? from docx import Document ; doc = Document() ; table = doc.add_table(rows=5, cols=3) ; table.cell(r,c).text = str(tabs[r][c]) ; doc.add_heading ; p = doc.add_paragraph ; p.add_run ; doc.add_picture ; 使用wordPad開啟會少最後一個row,可以用免費的LibreOffice](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/09/20220914154313_30.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言