本文实例讲述了python比较2个xml内容的方法。分享给大家供大家参考。具体分析如下: from xml.etree import ElementTree OK=True main_pid = 10000 loop_depth = 0 def compare_xml(left, right, key_info='.'): global loop_depth loop_depth += 1 if loop_depth == 1: print if left.tag != right.tag: print_diff(main_pid, key_info, 'diffta