xml.etree.ElementTree-.remove()功能的问题

时间:2019-06-10 08:27:06

标签: python xml python-3.x

我对xml.etree.ElementTree remove()函数有问题。我正在将数据从字符串解析到程序中,并希望从给定列表(下面的代码中的self.given_list)中删除与模式匹配的元素,但是当我启动程序时,它显示错误:

ValueError: list.remove(x): x not in list

即使我在上面打印它,也可以看到它存在。 代码如下所示:

     target_view_config = ET.fromstring(source_view_config)
     for source_item in target_view_config.findall('jobNames/string'):
             for target_item in self.given_list:
                 if((source_item.text) == target_item):
                     target_view_config.remove(source_item)
                     break

1 个答案:

答案 0 :(得分:0)

好吧,我自己解决了这个问题,方法是使用

调用一个对象
  static const TextStyle mediaDetailGenreText = TextStyle(color: ThemeColors.textColor, fontSize: 15, fontWeight: FontWeight.w500);
相关问题