首页 > 解决方案 > 需要拆分由多个分隔符分隔的文件内容并显示最长的长度行

问题描述

输入.txt

hi all.i hope all are doing well?
please help with the solution.i tried all the possible solution?

预期的o / p:

['hi all','i hope all are doing well,
 'please help with the solution','i tried all the possible solution']

标签: python

解决方案


解决此问题的另一种简单技术是使用拆分方法。我试图尽可能简单地解决它。

file = open("input.txt", "r")
Text = file.read()
Text = Text.replace(".", ",").replace("?", ",")
Text.split(",")
Text = Text[:-1]

推荐阅读