from simplified_scrapy import SimplifiedDoc, utils #simplified_scrapy is framework for extrcting data xml = utils.getFileContent('check_in.xml') doc = SimplifiedDoc(xml) #SimplifiedDoc is a library for parsing data such as HTML and XML nodes = doc.select('air:EDS_AirCheckInRQ').children print (nodes.tag) for x in nodes: print((doc.select('air:EDS_AirCheckInRQ')['Version']),(doc.select('com:Source'))) Here is my output:- 4.000 {'tag': 'com:Source', 'AirlineVendorID': 'CM'} 4.000 {'tag': 'com:Source', 'AirlineVendorID': 'CM'} 4.000 {'tag': 'com:Source', 'AirlineVendorID': 'CM'} 4.000 {'tag': 'com:Source', 'AirlineVendorID': 'CM'} 4.000 {'tag': 'com:Source', 'AirlineVendorID': 'CM'} 4.000 {'tag': 'com:Source', 'AirlineVendorID': 'CM'}這是我的 python 代碼,我只想在其中打印一次,但是當(dāng)我運(yùn)行它時(shí),它會(huì)給出打印多次的輸出。我只想打印一次。誰能幫我解決為什么打印多次而不是一次?
python 中多次打印?
當(dāng)年話下
2024-01-27 14:40:59