想问一下怎么从给定字符串中提取出来数字进行计算呢

img


想问一下怎么样才能从如图题目给定的这个字符串中提取出它们的成绩并进行计算求总成绩和平均成绩呢


str = 'Chinese=90 English=80 Math=78 Art=70'
sum = 0
count = 0
for temp in str.split(' '):
    score = int(temp.split('=')[-1])
    sum += score
    count += 1
print('总成绩是%s, 平均成绩是%s' % (sum, sum/count))