在Python中将Stanza转换为Paragraph

时间:2017-12-23 01:03:05

标签: python-3.x

我正在尝试创建一个将节转换为段落的python脚本。这种东西:

My mother’s maids, when they did sew and spin,
They sang sometimes a song of the field mouse,
That for because their livelihood was but so thin.

Would needs go seek her townish sister’s house.
Would needs She thought herself endured to much pain:
The stormy blasts her cave so sore did souse…

成为这样一个段落:

我妈妈的女仆,当他们缝制和旋转的时候,他们有时会唱一首田鼠的歌,因为他们的生计太瘦了。需要去寻找她的乡镇妹妹的房子。需要她认为自己忍受了很多痛苦:风雨如磐地冲击她的洞穴,因此疼痛咳嗽......

1 个答案:

答案 0 :(得分:0)

这是正则表达式的工作,而不是python。将\n+替换为(单个空格)。

Here’s a link to Regexr