How to split each words from several lines of a word file? (python)

前端 未结 3 1521
一整个雨季
一整个雨季 2021-01-28 10:32

I have a text file:

But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already          


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-28 10:57

    line.split() gives you a list which will be added to your lst list as a list object. Therefore rather than using lst.append(line) use lst.extend(line) for the correct output.

提交回复
热议问题