日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ElementTree中的getchildren and getiterator

發布時間:2024/8/24 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ElementTree中的getchildren and getiterator 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
36 # C:\Users\jeguan\Desktop\Test_1.txt37 #38 # <?xml version="1.0"?>39 # <data>40 # <country name="Liechtenstein">41 # <rank>1</rank>42 # <year>2008</year>43 # <gdppc>141100</gdppc>44 # <neighbor name="Austria" direction="E"/>45 # <neighbor name="Switzerland" direction="W"/>46 # </country>47 # <country name="Singapore">48 # <rank>4</rank>49 # <year>2011</year>50 # <gdppc>59900</gdppc>51 # <neighbor name="Malaysia" direction="N"/>52 # </country>53 # <country name="Panama">54 # <rank>68</rank>55 # <year>2011</year>56 # <gdppc>13600</gdppc>57 # <neighbor name="Costa Rica" direction="W"/>58 # <neighbor name="Colombia" direction="E"/>59 # </country>60 # </data>61 #######################################################################62 def func2():63 from xml.etree import ElementTree64 xlsfile = r'C:\Users\jeguan\Desktop\Test_1.txt'6566 root = ElementTree.parse(xlsfile).getroot()67 <span style="color:#FF0000;"><strong><span style="font-size:18px;"> ListNode = root.getiterator('rank')</span></strong></span>68 print(ListNode)69 # the output for print(ListNode) [<Element 'rank' at 0x6ffffc51450>, <Element 'rank' at 0x6ffffc51810>, <Element 'rank' at 0x6ffffc51950>]70 <span style="font-size:18px;color:#FF0000;"><strong>children = root.getchildren()</strong></span>71 print(children)72 # the output for print(children) is [<Element 'country' at 0x6ffffc50410>, <Element 'country' at 0x6ffffc507d0>, <Element 'country' at 0x6ffffc50910>] https://github.com/double12gzh/PythonLearning/blob/master/ElementTree.py

轉載于:https://www.cnblogs.com/double12gzh/p/10166231.html

總結

以上是生活随笔為你收集整理的ElementTree中的getchildren and getiterator的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。