#Python TQC考題905 字串資料刪除,datanew=data.replace(strold,strnew), f.write(datanew)
“””
txt檔內容如下:
Apple Kiwi Banana
Tomato Pear Durian
要將Tomato刪除
.replace(“Tomato”,””)
將Tomato換成什麼都沒有
“””
f_name = input()
string = input()
# TODO
with open(f_name,”r+”,encoding=”utf-8″) as file:
print(“=== Before the deletion”)
# TODO
data=file.read()
print(data)
print(“=== After the deletion”)
# TODO
dataNew = data.replace(string,””)
print(dataNew)
file.seek(0,0)
file.write(dataNew)

![Python如何做excel的樞紐分析? groupbyObj = df.groupby([‘A’, ‘B’]) ; groupbyObj.apply() 跟 groupbyObj.agg() 差異為何? result = groupbyObj .apply( function(df) -> Series ) ; result_agg = groupbyObj .agg( [‘mean’, ‘std’] ) ; aggfunc(Series) -> float Python如何做excel的樞紐分析? groupbyObj = df.groupby([‘A’, ‘B’]) ; groupbyObj.apply() 跟 groupbyObj.agg() 差異為何? result = groupbyObj .apply( function(df) -> Series ) ; result_agg = groupbyObj .agg( [‘mean’, ‘std’] ) ; aggfunc(Series) -> float](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230327140158_46.png?quality=90&zoom=2&ssl=1&resize=350%2C233)









近期留言