所以处理一个有这样的文件的作业,qbdata.txt:
Carson Palmer QB CIN 362 586 3970 26 20 61.8% 82.4
Alex Smith QB SF 204 342 2370 14 10 59.6% 82.1
Chad Henne QB MIA 301 490 3301 15 19 61.4% 75.4
Tony Romo QB DAL 148 213 1605 11 7 69.5% 94.9
Jay Cutler QB CHI 261 432 3274 23 16 60.4% 86.3
Jon Kitna QB DAL 209 318 2365 16 12 65.7% 88.9
Tom Brady QB NE 324 492 3900 36 4 65.9% 111.0
我需要修改for循环并制作一个列表,然后打印DAL QB及其评级,我所拥有的是:
qbfile = open("qbdata.txt", "r");
for aline in qbfile:
values = aline.split()
if aline = 4:
print('QB ', values[0], values[1], 'had a rating of ', values[10] )
if aline = 6:
print('QB ', values[0], values[1], 'had a rating of ', values[10] )
qbfile.close();
尝试了几件不同的事情并查看了其他帖子,但似乎无法弄明白......