Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:Search.xlsx文件以查找特定的XML标记_Python_Xml_Xlsx - Fatal编程技术网

Python:Search.xlsx文件以查找特定的XML标记

Python:Search.xlsx文件以查找特定的XML标记,python,xml,xlsx,Python,Xml,Xlsx,我想在.xlsx文件中搜索某个XML标记-例如,检查.xlsx文件中是否存在标记 我目前的计划是解压缩.xlsx文件,然后在所有.xml文件中搜索有问题的标记。是否有标准库或更简单的方法来执行此操作?def xlsxHasEntity(文件名): def xlsxHasEntity(filename): in

我想在.xlsx文件中搜索某个XML标记-例如,检查.xlsx文件中是否存在标记

我目前的计划是解压缩.xlsx文件,然后在所有.xml文件中搜索有问题的标记。是否有标准库或更简单的方法来执行此操作?

def xlsxHasEntity(文件名):
def xlsxHasEntity(filename):                                                                                            
   input_zip = ZipFile(filename)                                                   
   xml_files = [name for name in input_zip.namelist() if name.endswith("xml")]  
   raw_files = {name: input_zip.read(name) for name in xml_files}                                                      
   for raw_filename in raw_files:                                                  
      if "<!ENTITY" in raw_files[raw_filename]:                                    
         return True                                                               
   return False  
input_zip=ZipFile(文件名) xml_files=[name for name in input_zip.namelist()如果name.endswith(“xml”)] 原始文件={name:input_zip.read(name)for name in xml_files} 对于原始文件中的原始文件名: 如果“