#Python TQC考題909
f_name = “data.dat”
file = open(f_name,”wb”)
# TODO
for i in range(5):
inp = input()
b_inp = bytearray(inp+”\n”,”utf-8″)
file.write(b_inp)
file.close()
print(‘The content of “data.dat”:’)
with open(f_name,”rb”) as file:
for line in file:
print(line.decode(“utf-8”))
“””
The content of “data.dat”:
“””

#只要加encoding=”utf-8″
#b模式都用不到,如: rb, wb



![Python: 如何使用pandas.to_numeric ( df[‘numbers’], errors=’coerce’) 將非數值型資料轉為NaN? df[‘numbers’].describe() 簡述統計資料 Python: 如何使用pandas.to_numeric ( df[‘numbers’], errors=’coerce’) 將非數值型資料轉為NaN? df[‘numbers’].describe() 簡述統計資料](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2024/05/20240501052102_0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index) Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250420212553_0_6fb2c3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python: List[ pandas.Series ] 轉DataFrame技巧:正確理解row和column的關係,同 concat( List[ pandas.Series ], axis=1 ).T Python: List[ pandas.Series ] 轉DataFrame技巧:正確理解row和column的關係,同 concat( List[ pandas.Series ], axis=1 ).T](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250422150133_0_1cfa94.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




近期留言