python - 需要拆分由多个分隔符分隔的文件内容并显示最长的长度行
问题描述
输入.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']
解决方案
解决此问题的另一种简单技术是使用拆分方法。我试图尽可能简单地解决它。
file = open("input.txt", "r")
Text = file.read()
Text = Text.replace(".", ",").replace("?", ",")
Text.split(",")
Text = Text[:-1]
推荐阅读
- python-3.x - 如何使用python将回文字符串从一个文件复制到另一个文件
- angular - 根据Angular 9中的切换按钮更改显示/隐藏div
- reactjs - Axios React/Redux - 使用 thunk 动作创建器时不触发?
- node.js - 请求的资源上不存在“Access-Control-Allow-Origin”标头。NodejS Express
- tcl - Tcl如何将参数传递给proc
- python - X 轴标签在 Pandas 的 Pivot Dataframe 图中不可见
- vue.js - Vuejs 严格模式 - 错误:[vuex] 不要在突变处理程序之外改变 vuex 存储状态。我确实已经正确使用了突变
- c# - 服务器端 Blazor 中的 Google 身份验证不起作用
- amazon-web-services - AWS CDK - 云观察
- javascript - 在不刷新页面的情况下动态更改值