0
我在这里找了几个小时寻找解决方案,但找不到一个解决方案。也许有人可以帮助我或指出类似的问题?while循环跳过python中的函数?
我有一个while循环的功能。在每一行的功能迭代在一个文本文件:
def parser():
for line in f:
print(line)
f = open('textfile.txt', 'r')
count = 0
while count < 7:
parser()
count += 1
print(count)
我的输出如下:
text file line 1
text file line 2
text file line 3
1
2
3
4
5
6
我最初的目标是每个后+1再次调用该函数:
text file line 1
text file line 2
text file line 3
1
text file line 1
text file line 2
text file line 3
2
text file line 1
text file line 2
text file line 3
3
...等等。
道歉,如果这其实是事先复制和感谢!
那么快感谢您的帮助! – Sils10