如何在python中将一个文本字符串拆分为两列

2024-03-29 09:51:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在努力将文件文本的字符串拆分为两列。 在我把课文分成句子之后

for s in sentences:
    row = s.strip()            
    print(row)

它在同一列中为我提供了以下输出:

['1'
 "It is hands-down the best sporting museum in Australia
The kids (and dad) loved the interactive sports section
The amount of Olympic memorabilia was outstanding    
Don't miss going to this iconic venue."]
['2'
 "...
  ..."]

预期输出:

No     sentences
1     It is hands-down the best sporting museum in Australia
1     The kids (and dad) loved the interactive sports section
1     The amount of Olympic memorabilia was outstanding    
1     Don't miss going to this iconic venue.
2     ...
2     ...

任何人有任何想法,请帮助!你知道吗


Tags: andtheinissentencesitkidsrow