#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: pandas.DataFrame的串接 pandas.concat() #concatenate 連接, 如何重新排列columns 順序? df[[“甲”, “乙”, “丙”]] ; df.reindex( columns = [“甲”, “乙”, “丙”] ) Python: pandas.DataFrame的串接 pandas.concat() #concatenate 連接, 如何重新排列columns 順序? df[[“甲”, “乙”, “丙”]] ; df.reindex( columns = [“甲”, “乙”, “丙”] )](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/05/20241120092030_0_98dff3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python struct.pack() 將整數轉換為bytes ; while list: str1=list[0] ; 中間內容; list=[1:] #切片 ,遍歷list中的每一個元素,跟for i in list 類似 ; timeit() #計時 Python struct.pack() 將整數轉換為bytes ; while list: str1=list[0] ; 中間內容; list=[1:] #切片 ,遍歷list中的每一個元素,跟for i in list 類似 ; timeit() #計時](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/10/20221012095050_42.png?quality=90&zoom=2&ssl=1&resize=350%2C233)







近期留言