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