python_data['division'].append(int(split[3])) 中的语法无效

Invalid syntax in python_data['division'].append(int(split[3]))

获取无效语法但不确定原因。查看具有以下代码的行:data['division'].append(int(split[3]))

def getBMData(filename):
    """Read the contents of the given file. Assumes the file
    in a comma-seperated format, with 6 elements in each entry:
    0. Name (string), 1. Gender (string), 2. Age (int),
    3. Division (int), 4. Country (string), 5. Overall time (float)
    Returns: dict containing a list for each of the 6 variables."""
    
    data = {}
    f = open(filename)
    line = f.readline()
    data['name'], data['gender'], data['age'] = [], [], []
    data['division'], data['country'], data['time'] = [], [], []
    while line != '':
        split = line.split(',')
        data['name'].append(split[0])
        data['gender'].append(split[1])
        data['age'].append(int(split[2])
        data['division'].append(int(split[3]))
        data['country'].append(split[4])
        data['time'].append(float(split[5][:-1])) #remove \n
        line = f.readline()
    f.close()
    return data
                           
   

括号没有闭合

data["age"].append(int(split[2]) <- here

改为:

data["age"].append(int(split[2]))