【发布时间】:2017-08-27 14:21:48
【问题描述】:
我有一篇来自 NLTK 路透社语料库的文章,作为原始字符串
>>>from nltk.corpus import reuters
>>>retail_article = reuters.raw('training/8173')
>>>print (retail_article)
"FRENCH GDP SHOULD RISE 2.3 PCT IN 1988 - MINISTRY\n French gross domestic
product should grow\n by 2.3 pct in 1988 after two pct growth this year
and 2.1 pct\n in 1986, the Finance Ministry said.\n The latest
forecast,...
我希望文本位于单独的行中,而不是 \n。我该怎么做?
>>>type(retail_article)
str
decode() 不适用于字符串,encode() 没有给出想要的结果。
TIA
【问题讨论】:
标签: string python-3.x nlp nltk