这可能是一个真正愚蠢的问题,但我还没有找到答案.
一旦我根据需要修改了xml树,我该如何将其写回文件?
码:
workbook = open("C:\\Users\\rabdel.WINCMPT\\Documents\\Retail Footwear.twb")
soup = BeautifulSoup(workbook)
for dashboard in soup.findAll("dashboard"):
print dashboard["name"]
if dashboard["name"] == "S1":
dashboard.extract()
for window in soup.findAll("window"):
print "class:",window["class"]
if "name" in [x[0] for x in window.attrs]:
print "name:",window["name"]
if window["name"] == "S1":
window.extract()
最佳答案
原文链接:https://www.f2er.com/python/439388.html