Skip to content Skip to sidebar Skip to footer

How To Split Each Line From File To It's Own String In Python?

I have a file with a bunch of information with this following format: New York Jets I am trying to get each line of the file into it's own string. Fo

Solution 1:

from xml.domimport minidom

xmldoc = minidom.parse('filename.txt')

itemlist = xmldoc.getElementsByTagName('item')

for s in itemlist: print(s.attributes['name'].value)

you can read a file having tags like this, and retrieve the values.

Post a Comment for "How To Split Each Line From File To It's Own String In Python?"