I'am designing a code in python for extract information from a xml file with a function with two variables. The code is working with one file:
import re
def Readfiles(XFile):
Id=''
des=''
with open(XFile,"r",encoding="utf-8") as h:
for line in h:
wline = line.rstrip("\n")
if re.search("^ID\s{3}",wline):
res=re.search(r"^ID\s{3}",wline)
Id=res.group(1)
if re.search("^DE\s{3}",wline):
res=re.search("^DE\s{3}",wline)
des=res.group(1)
return(Id,des)
(Identificator,desc)=Readfiles("rte.xml", "pre.xml", "ytl.xml")
print("Nom:",Identificator)
print("Descrip:",desc)
On the other hand, I want to read more files (tree xml in the code) in a same time but it give me error.
Thank for your help.
CodePudding user response:
for f in ("rte.xml", "pre.xml", "ytl.xml"):
(Identificator,desc)=Readfiles(f)
The error is that Readfiles
is called with three arguments but it has only one parameter.