我是python的新用户。我有这样Python - >组织列表文本文件
NEW YORK ....... from
31 Chatty, Seager Aarhaus
Atlas, Jones Abertham
Polly, Manning Antwerpen
Amazon, Brittle Belchental
LONDON ........ for
31 Park Dattemroed
Eleanor, Mallett Civeta Naples
3 Aurora Frigate Ljubljana
为.txt格式列表(和.csv),我想有
NEW YORK ....... from 31 Chatty, Seager Aarhaus
NEW YORK ....... from Atlas, Jones Abertham
NEW YORK ....... from Polly, Manning Antwerpen
NEW YORK ....... from Amazon, Brittle Belchental
LONDON ........ for 31 Park Dattemroed
LONDON ........ for Eleanor, Mallett Civeta Naples
LONDON ........ for 3 Aurora Frigate Ljubljana
我尝试使用正则表达式,但我不能获得满意的结果。
我不知道是否有办法做到这一点。
“*我不知道是否有办法做到这一点。*” - 就在这里。事实上,有很多方法可以做到这一点。哪一种方法取决于许多你没有分享的因素。也许你可以告诉我们你到目前为止所尝试过的东西,以及它如何工作或没有。然后我们可以建立在你的工作上。 –
为什么'LONDON'后面有8个点,但是'NEW YORK'后面只有7个点?如果你想使用正则表达式,你可能需要一个[常规语言](http://stackoverflow.com/questions/6718202/what-is-a-regular-language) –
谢谢,我试图按照大写字母话。我应该发过来,但我什么都没有。 –