• xlrd 简单使用统计成绩


      一张名单表中存有本院考号和姓名,一张成绩表中存有全校学生的考号、分数、排名。使用了xlrd package,挺好用的。

     1 import xlrd
     2 
     3 nameBook = xlrd.open_workbook("/home/chm/Documents/namesheet.xls")
     4 markBook = xlrd.open_workbook("/home/chm/Documents/mark.xls")
     5 
     6 nameSheet = nameBook.sheet_by_index(0)
     7 markSheet = markBook.sheet_by_index(0)
     8 
     9 fullmark     = 0
    10 aboveninety    = 0
    11 aboveeighty = 0
    12 abovesixty    = 0
    13 belowsixty    = 0
    14 
    15 for rx in range(markSheet.nrows):
    16     for ry in range(nameSheet.nrows):
    17         studentId=(int)(markSheet.cell_value(rx,2)) 
    18         if (studentId/1000000000 == 1023) and studentId%100 == nameSheet.cell_value(ry,0):
    19             mark = markSheet.cell_value(rx,3)
    20             print nameSheet.cell_value(ry,1),mark
    21             
    22             if mark == 100:
    23                 fullmark     +=1
    24             elif mark >=90:
    25                 aboveninety +=1
    26             elif mark >=80:
    27                 aboveeighty +=1
    28             elif mark >=60:
    29                 abovesixty    += 1
    30             else:
    31                 belowsixty     += 1
    32 
    33 print "fullmarks:\t",fullmark
    34 print "90~100:\t\t",aboveninety
    35 print "80~90:\t\t",aboveeighty
    36 print "60~80:\t\t",abovesixty
    37 print "0~60:\t\t",belowsixty
  • 相关阅读:
    2012第50周星期日
    2012第51周星期一
    2012第51周星期三
    2012第51周六
    2012第52周一
    2012第51周五冬至
    2012第51周星期二
    2012第52周二
    2012年第51周日
    2012第51周星期四
  • 原文地址:https://www.cnblogs.com/invisible/p/2821196.html
Copyright © 2020-2023  润新知