Below is a ready-to-use script. Review and adapt variables to your environment.
#!/usr/bin/env python3
import sys,re
pat = re.compile(r'^# Time:.*|^# Query_time: (\\S+)')
with open(sys.argv[1]) as f:
for line in f:
m = pat.match(line)
if m and len(m.groups())==1:
print(m.group(1))