美文网首页
英语录音检查程序

英语录音检查程序

作者: AndyDennisRob | 来源:发表于2020-03-07 14:54 被阅读0次

为了检查录音,可笔者比较懒,不想一个一个对着。特意写了个python程序来统计。前提需要知道已完成作业的学生的编号。

安装必要的库

pip install xlrd
pip install xlwt
pip install xlutils

程序部分

首先,引入需要import的库/类

import xlrd
import xlwt
from xlutils.copy import copy
import sys

接收输入进来的学生到数组中,并且返回

def inputDone():
    # 非-1持续输入
    j = eval(input("请输入已完成的学生编号: "))
    doneS = []
    while j != -1:
        doneS.append(j)
        j = eval(input("请输入已完成的学生编号: "))
    print("--------输入已完成学生编号完毕----------")
    return doneS

标记已完成的学生

def noteDone(file, time, doneS, sheet_index=0):
    workbook = xlrd.open_workbook(file)
    wb = copy(workbook)
    ws = wb.get_sheet(sheet_index)
    for num in doneS:
        ws.write(num - 1, time, "完成")
    wb.save(file)
    print("---------写入已完成作业完成----------")

找出未完成的学生

def findUndo(file, time, sheet_index=0):
    workbook = xlrd.open_workbook(file)
    sheet = workbook.sheet_by_index(sheet_index)
    undo = []
    for i in range(1, sheet.nrows):
        cell_value = sheet.cell(i, time).value
        if cell_value != '完成':
            undo.append(sheet.cell(i, 0).value)
    print("----------找出未完成作业的学生完毕-----------")
    return undo

将未完成的学生写入sheet2

def writeUndo(file, time, undoS, sheet_index=1):
    workbook = xlrd.open_workbook(file)
    wb = copy(workbook)
    ws = wb.get_sheet(sheet_index)
    sheet = workbook.sheet_by_index(sheet_index)
    row = 1
    for i in range(1, sheet.nrows):
        ws.write(i, time - 1, " ")
    for name in undoS:
        # print(name)
        ws.write(row, time - 1, name)
        row += 1
    wb.save(file)
    print("----------写入未完成作业名单完毕------------")

main函数

if __name__ == '__main__':
    # 操作的文件
    file = 'Excel/test.xlsx'
    # 第几次作业
    time = 2
    # doneS = inputDone()
    # 请不要输入 1
    doneS = [3, 5]
    if 1 in doneS:
        print("1 不允许在已完成的学生编号中")
        sys.exit()
    print("第{}次作业已完成学生的编号: {}".format(time, doneS))
    noteDone(file, time, doneS)
    undo = findUndo(file, time)
    print("未完成的学生: ", undo)
    writeUndo(file, time, undo)

    print("----> 感谢使用  <----")

这是我的项目结构,其实很简单的。


项目结构
运行结果
sheet1,同学名单
sheet2,未完成同学名单

这里第一次作业不管哦,是之前演示的。如果你想修改第一次作业的数据,只需把main函数中的time改为1即可。
hhha,我真是一个懒惰的英语助手。

相关文章

  • 英语录音检查程序

    为了检查录音,可笔者比较懒,不想一个一个对着。特意写了个python程序来统计。前提需要知道已完成作业的学生的编号...

  • 11月1日

    A:早上起床听读英语录音 M:不愿意听 B:虽然现在英语成绩还行,但是听读英语录音是练习英语语感的好方法,每周英语...

  • 开始英语录音

    2020年的时候,跟朋友一起在小打卡进行了英语语音的打卡的打卡。 2021年开始决定换一种方式,今天尝试了一下,在...

  • 2017年3月第三周成长回顾

    输入与输出 写作1篇,英语早读3天,英语早读录音1首,公众号文章录音一首 1. 公众号文章《英文早读课给我带来的...

  • 学英语,为什么要常听参考录音?

    参考录音指来自各种途径的供英语学习者参考用的发音标准的音频材料。比如,朗文、韦伯斯特等词典提供的录音,英语课本的配...

  • 英语12- 我想进你们公司

    点击听我的录音 英语原文 A: We also have unlimited supply of snacks. ...

  • 英语11- 好吃不要只会delicious

    点击听我的录音 英语原文 A:And? B:we have flextime, free meals, year-...

  • 英语06- 5句话表白老师

    点击听我的录音 英语原文 Dear teacher, I'm grateful to be your studen...

  • 英语08- 秋日穿搭

    点击听我录音 英语原文 Fall is a good time to purchase some boots. T...

  • 有趣的英语录音

    今天,我们上完英语课后,就进入了我们每节课都很期待的游戏环节。 老师把电脑调到了总屏幕,然后就点开了游戏教程,原来...

网友评论

      本文标题:英语录音检查程序

      本文链接:https://www.haomeiwen.com/subject/cvjcdhtx.html