#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: 如何用numpy.ndarray的reshape 將3D array轉為2D array,再轉為pandas.DataFrame? arr.reshape( arr.shape[0] * arr.shape[1] , -1) Python: 如何用numpy.ndarray的reshape 將3D array轉為2D array,再轉為pandas.DataFrame? arr.reshape( arr.shape[0] * arr.shape[1] , -1)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230320082325_85.png?quality=90&zoom=2&ssl=1&resize=350%2C233)





近期留言