简体   繁体   English

Python字符串带,用于Twitter feed上的新行

[英]Python String strip for new lines on a twitter feed

I have a twitter text like this what i am trying is to trim all new lines and make it a single string 我有一个像这样的推特文本我正在尝试修剪所有新行并将其变成单个字符串

Text is-------------> RT @KajuBadamChor: Who are we?. 文字是-------------> RT @KajuBadamChor:我们是谁? Indian. 印度人

what do we wan't? 我们想要什么?

American Visa. 美国签证。

Why do we wan't it?. 我们为什么不这样做?

we wanna work for naughty America. 我们想为顽皮的美国工作。

But why? 但为什么?

Because YPD2. 因为是YPD2。

Expecting 期待中

Text is-------------> RT @KajuBadamChor: Who are we?.Indian.what do we wan't?American Visa.Why do we wan't it?.we wanna work for naughty America.But why?Because YPD2. 文字是-------------> RT @KajuBadamChor:我们是谁?印度。我们要什么?美国签证。我们为什么不想要?。我们想为顽皮的美国,但是为什么呢?因为是YPD2。

i have tried var[i]['text'].rstrip("\\n") 我已经尝试过var [i] ['text']。rstrip(“ \\ n”)

that is right strip for new line characters but it doesn't seems to be giving the o/pi expect , i have been coding python for last few days hence i am sure i am missing something very simple , Help please , suggestions willd o , not expecting you to give me a code solution :) 这是换行符的正确选择,但似乎并没有达到o / pi的期望,我最近几天一直在使用python进行编码,因此我确定我缺少一些非常简单的东西,请帮忙,建议将o,不希望您给我一个代码解决方案:)

Thanks 谢谢

var[i]['text'] = var[i]['text'].replace('\n', '')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM