I run the python 3 code which from others code as following in the python 2.7 environment, there is error as following, please give me some hints how to solve it, thanks! If you want more information, please tell me.
python code:
#! /usr/bin/env python
from __future__ import print_function
import argparse
from collections import defaultdict
import numpy as np
import os
import sys
import utils
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('target')
args = parser.parse_args()
target = defaultdict(list)
for i, line in enumerate(sys.stdin):
filename, score, *rect = line.strip().split()
name, _ = os.path.splitext(filename)
score = float(score)
rect = tuple(map(float, rect))
target[name].append((score, rect))
if (i + 1) % 1000 == 0:
print(i + 1, file=sys.stderr)
for name in target.keys():
target[name] = np.array(target[name], dtype=utils.dtype)
target[name].sort(order=('score',))
target[name][:] = target[name][::-1]
np.savez_compressed(args.target, **target)
the error:
File "./scripts/lo.py", line 19
filename, score, *rect = line.strip().split()
^
SyntaxError: invalid syntax