繁体   English   中英

删除笔画后如何删除单词,单词在文本文件中每个句子很好一行

[英]How to do to remove the word after removing a stroke, a word is in a text file each sentence well a line

文件内容:

this is a simple example of app-

lying translinelation rules

我的代码:

arq = open('speech.txt', 'r') 
line = ar.read().replace('-','').split()
print(line)

退出我的代码:

 ['this', 'is', 'a', 'simple', 'example', 'of', ***'app', 'lying'***, 'translinelation', 'rules']

正确的输出:

 ['this', 'is', 'a', 'simple', 'example', 'of', *'**applying'**,* 'translinelation', 'rules']

我突出显示了发生错误的单词。

 applying

有人能帮我吗。

您还需要替换新行:

content = "this is a simple example of app-\nlying translinelation rules"
line = content.replace('-\n','').split()
print(line)

https://repl.it/repls/JollyFamiliarQbasic

暂无
暂无

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

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