我设法提出了以下代码,该代码使我可以两次查询数据文件以同时获取不同的信息。但是,它似乎没有用。有人可以在这里发现我在做什么错吗?
print('Start')
def getAllTimes(arg1):
task1 = arg1
if task1 == 1:
textfile = open(logfile, 'r')
filetext = textfile.read()
textfile.close()
matchesBegin = beginStr in filetext
matchesEnd = endStr in filetext
return(matchesBegin,matchesEnd)
elif task1 == 2:
AllTimeStamps = [ x.split(' ')[0][1:-1] for x in open(logfile).readlines() ]
AllUniqTimeStamps = set(AllTimeStamps)
return AllUniqTimeStamps
etime = 0
AllTimes = []
for etime in range(1,2):
AllTimeZ = threading.Thread(target=getAllTimes, args=[etime])
AllTimes.append(AllTimeZ)
AllTimeZ.start()
for TheTimes in AllTimes:
TheTimes.join()
print TheTimes
print('Done')
上面的代码运行后,我想确保可以查询在函数中创建的任何变量的内容。我所说的变量是:matchesBegin, matchesEnd, AllUniqTimestamps