【发布时间】:2021-12-19 22:02:11
【问题描述】:
python新手-
我需要创建一个“while”循环来搜索某个字符串在文本文件中的位置。
文件中的所有字符都已设置为整数 (x = len(all)),所以现在我需要一个循环来搜索某个字符串的索引/位置。
这就是我现在所处的位置:
string = 'found'
index = 0
while index < x:
if ????
然后它应该打印出类似的东西
String found between (startIndex) and (endIndex)
【问题讨论】:
-
请提供输入文件的示例和匹配的预期输出。另外,这是作业吗?
-
不是为了作业
标签: python loops parsing while-loop