我有一个我开发/var/tmp
并工作的脚本......当我出于某种原因移动到所需的目录时,它返回以下错误:
Traceback (most recent call last):
File "tail.py", line 104, in <module>
test=isItAlive(line)
File "tail.py", line 55, in isItAlive
return test
UnboundLocalError: local variable 'test' referenced before assignment
它抱怨的功能是:
def isItAlive(text):
with open(valcsv) as f:
searches = [x.split(',')[1] for x in f.read().splitlines()]
for search in searches:
# print search
if not search in text:
test="TOBEADDED"
else:
test=search
break
return test
f.close()