這個錯誤是由於xml解析器對&有限制url
解析方案:把這&符號去掉3d
下面是個人問題解決方案: import oscode
import re listdir =['D:/test']xml
for i in listdir:blog
for root, dirs, files in os.walk(i): for file in files: url = str(root) + str("/") + str(file) print(url) f = open(url, encoding="utf-8") text = f.read() text = re.sub('&','',text) f.close() with open(url,"w",encoding="utf-8") as f1: f1.write(text)