ElementTree中的getchildren and getiterator

 36 # C:\Users\jeguan\Desktop\Test_1.txt
 37 #
 38 # 
 39 # 
 40 #       
 41 #           1
 42 #           2008
 43 #           141100
 44 #           
 45 #           
 46 #       
 47 #       
 48 #           4
 49 #           2011
 50 #           59900
 51 #           
 52 #       
 53 #       
 54 #           68
 55 #           2011
 56 #           13600
 57 #           
 58 #           
 59 #       
 60 # 
 61 #######################################################################
 62 def func2():
 63     from xml.etree import ElementTree
 64     xlsfile = r'C:\Users\jeguan\Desktop\Test_1.txt'
 65
 66     root = ElementTree.parse(xlsfile).getroot()
 67     ListNode = root.getiterator('rank')
 68     print(ListNode)
 69     # the output for print(ListNode) [, , ]
 70     children = root.getchildren()
 71     print(children)
 72     # the output for print(children) is [, , ]
https://github.com/double12gzh/PythonLearning/blob/master/ElementTree.py

转载于:https://www.cnblogs.com/double12gzh/p/10166231.html

你可能感兴趣的:(ElementTree中的getchildren and getiterator)