我正在尝试向我的程序添加一个新部分,该部分在我们的服务器上搜索机器人并删除它们,但我遇到了一个停止显示的问题:每当程序进入第二部分(我已经添加) “readFirst”的输出是“[]”。当接下来的几行运行时,出于显而易见的原因,我得到一个“列表索引超出范围”错误。
我不知道为什么会发生这种情况,因为 readlines 变量不应该由程序的两个部分共享。
这是代码:
while runTimes >= 0:
#Cycles through .php files
openedProg = glob.glob('*.php')
openedProg = openedProg[currentPhp:currentPhp+1]
progInput = ''.join(openedProg)
if progInput != '':
theBot = open(progInput,'r')
#Singles out "$output" on this particular line and closes the process
readFourthFromBottom = theBot.readlines()
wholeLine = (readFourthFromBottom[-4])
output = wholeLine[4:11]
#Singles out "set_time_limit(0)"
readFirst = theBot.readlines()
print(readFirst)
wholeLine2 = (readFirst[0])
output2 = wholeLine2[7:24]
print(output2)
theBot.close()
if progInput == '':
currentPhp = -1