0
我已得到NLTK的路透社語料庫的文章,作爲一個原始字符串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