How to use split function for file in python?

后端 未结 3 1671
独厮守ぢ
独厮守ぢ 2021-01-28 05:53

I have a file with a bunch of information. For example, all of the lines follow the same pattern as this:

     Nebraska
         


        
3条回答
  •  我在风中等你
    2021-01-28 06:15

    s = 'Nebraska'
    

    in:

    s.split('>')
    

    out:

    ['

    in:

    s.split('>')[1].split('<')
    

    out:

    ['Nebraska', '/school']
    

    in:

    s.split('>')[1].split('<')[0]
    

    out:

    'Nebraska'
    

提交回复
热议问题