Diary of LX

  • 抽签
  • 学习
  • 技术
  • 说说
  • 作业
  • 工具
  • 归档
  • 友链
  • 开往
  • 虫洞-个站商店
  • 虫洞-十年之约
  • GitHub
  • Telegram
  • Twitter
  • Link

【原创】python制作抽签器,可导入excel

  • lx
  • 2022-01-02
  • 0

上学校技术课做的,没啥技术含量

抽签

import random
import xlrd
import xlwt
import time
'''
删了。。。。。。
print("请导入文档,需要符合格式,只能为xls格式,请输入完整路径")
wenjian = "r'" + str(input()) + "'"
print(wenjian)
'''
print("提示:如果要改文件,请到路径D:\Files\mingdan.xls")
time.sleep(1)
print("欢迎开始抽名字")
mingdan = xlrd.open_workbook(r'D:\files\mingdan.xls') #导入
sheet = mingdan.sheet_by_name('Sheet1') #表
nrows = int(sheet.nrows) #行数
s = 1
while s == 1:

print("请输入你想要抽的人数,总共有",nrows,"个人")
renshu = int(input())
if renshu > nrows or renshu < 1:
    print("你输入的数字不太对吧,臣妾做不到啊")
else:
    list = []
    list0 = []
    print("抽取中……请稍后………")
    for i in range(nrows):
        list.append(i)
    for i in range(renshu):
        chou = int(random.randint(0,nrows-1-i))
        list0.append(list[chou])
        del list[chou]
    time.sleep(2)
    print("抽完了")
    for i in range(len(list0)):
        chou = list0[i]
        mz = str(sheet.cell(chou,0).value)
        if mz == "凌霄之上":  #作弊区(抽不到)
            print("!系统故障,The Source Can Not Found!")
            continue
        xh = int(sheet.cell(chou,1).value)
        time.sleep(0.5)
        print("恭喜!",mz,",学号:",xh)
time.sleep(3)
print("还要继续吗,输入任意键继续")
input()
© 2023 Diary of LX

Theme by Wing

           萌ICP备20228887号
  • {{ item.name }}
  • {{ item.name }}