社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

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

Julie • 5 年前 • 1466 次点击  

我正在努力将一个文件文本的字符串分成两个独立的列。 在我把文本分成句子之后

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     ...

任何人有任何想法,请帮忙!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/44671
 
1466 次点击  
文章 [ 1 ]  |  最新文章 5 年前