Python读取excel

import xlrd
if __name__ == '__main__':
    workbook = xlrd.open_workbook('D:\\pycharm_demo\\1.xlsx')
    worksheet1 = workbook.sheet_by_name(u'Sheet1')
    nrows = worksheet1.nrows
    ncols = worksheet1.ncols
    x = dict()
    for i in range(1, nrows):
        boolean = worksheet1.row(i)[0].value < worksheet1.row(i)[1].value
        if i == 1:
            x = {worksheet1.row(i)[3].value: worksheet1.row(i)[5].value}
        else:
            if worksheet1.row(i)[3].value in x:
                temp = x[worksheet1.row(i)[3].value]
                x[worksheet1.row(i)[3].value] = worksheet1.row(i)[5].value + temp
            else:
                x[worksheet1.row(i)[3].value] = worksheet1.row(i)[5].value

        print(boolean, worksheet1.row_values(i))

    print(x)

#验证工号,姓名,sn号是否一一对应
#开始时间必须早于结束时间
#统计用户使用时长,昨天使用时长

你可能感兴趣的:(软件测试)