小编Mit*_*her的帖子

这段代码如何转换成python 2?

import csv

with open('scores.csv') as handle:
    reader = csv.reader(handle)
    for row in list(reader)[1:]:
        user, *scores = row
        average = sum([int(score) for score in scores]) / len(scores)
        print (
            "{user} has average of {average}".format(user=user,average=average)
        ) 
Run Code Online (Sandbox Code Playgroud)

由于*分数,此代码在python 2.7中不起作用.我如何将其更改为python 2.7,因为我不知道如何?

此代码取自此主题:行平均CSV Python

python csv python-2.7

0
推荐指数
1
解决办法
59
查看次数

标签 统计

csv ×1

python ×1

python-2.7 ×1