|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 芥末丶涂鸦 于 2017-7-9 16:44 编辑
计算成绩
- a =input('请输入分数')
- b = a.isdigit()
- if b ==1:
- a = int(a)
- if 60<=a<=80:
- print('成绩为C')
- if 90<=a<=100:
- print('成绩为A')
- if 80<=a<90:
- print('成绩为B')
- if 0<a<60:
- print('不及格')
- else:
- print('输入有误')
复制代码
用户登录密码验证
- mima = ('wo123')
- yanzheng = input('请输入密码')
- i = 3
- while i and i>1:
- if mima == yanzheng:
- print('进入程序...')
- break
- if '.' in yanzheng:
- print('不能有点,铁这次就原谅你了。')
- yanzheng = input('请输入密码')
- continue
- #跳出当前循环,从新进入循环判断
- else:
- i -=1
- print('你输入密码有误,还剩',i,'次机会')
- yanzheng = input('请输入密码')
复制代码
仓库管理系统
更新日期2017.7.7
- import easygui as  g
- zhanghao = ['123','789','132','w0102937']
- mima = ['321','565','321','pp16354ttp']
- ############帐号写入数据库
- def xierumima(zhanghao,mima):
-     import xlutils, xlrd, xlwt
-     from xlutils.copy import copy
-     from openpyxl import load_workbook
-     # 打开路径
-     oldWb = xlrd.open_workbook('密码.xls', formatting_info=True)
-     # 复制
-     newWb = copy(oldWb)
-     # 工作薄
-     newWs = newWb.get_sheet(0)
-     ########################################
-     # 判断是否为空
-     num = 0
-     table = oldWb.sheets()[0]
-     num = int(table.cell(6,1).value)  # 获取特定单元格内容
-     num = num + 1
-     #写入
-     newWs.write(0,num,zhanghao )
-     newWs.write(1,num,mima)
-     newWs.write(6,1,num)
-     # 保存
-     newWb.save('密码.xls')
- ############注册帐号
- def zhucezhanghao():
-     import easygui as g
-     msg = "请认真填写并记录,切记!!!"
-     title = "账号中心"
-     fieldNames = ["*工号", "*真实姓名", "*密码", "*重复密码", "*手机号码",'*部门','*座机','*入厂日期']
-     fieldValues = []
-     fieldValues = g.multenterbox(msg, title, fieldNames)
-     # print(fieldValues)
-     while True:
-         if fieldValues == None:
-             break
-         errmsg = ""
-         for i in range(len(fieldNames)):
-             option = fieldNames.strip()
-             if fieldValues.strip() == "" and option[0] == "*":
-                 errmsg += ("【%s】为必填项   " % fieldNames)
-         if fieldValues[2] != fieldValues[3]:
-             g.msgbox('两次密码输入不一致')
-             zhucezhanghao()
-         if errmsg == "":
-             g.msgbox('注册成功')
-             zhanghao = fieldValues[0]
-             mima = fieldValues[2]
-             xierumima(zhanghao, mima)
-             break
-         fieldValues = g.multenterbox(errmsg, title, fieldNames, fieldValues)
-     kaitouchengxu()
- ############登录程序
- def dengluchengxu():
- try:
-     msg = "请输入用户名和密码"
-     title = "用户登录接口"
-     user_info = []
-     user_info = g.multpasswordbox(msg,title,("用户名","密码"))
-     zhanghaoyanzheng =zhanghao.index(user_info[0]) #将帐号的元素位置找到
-     if mima[zhanghaoyanzheng] == user_info[1]:#因为帐号和密码是成对出现,将帐号的元素位置引入密码列表与用户输入密码进行匹配以达到验证密码的目的.
-         g.msgbox('登录成功')
-         ceshiyong()
-     else:
-         g.msgbox('帐号或密码错误!!!')
-         dengluchengxu()
- except ValueError:
-     g.msgbox('帐号或密码错误!!!')
-     dengluchengxu()
- ########开头选择程序
- def kaitouchengxu():
-     xuanze =  g.buttonbox(msg='这是一个超越RMS的系统', title='test', choices=('开始使用', '退出使用', '注册帐号'), image='')#返回值是字符串类型按钮标题名
-     if  xuanze == '开始使用':
-      dengluchengxu()
-     if  xuanze == '退出使用':
-         g.msgbox('欢迎下次使用',ok_button="确认")
-     if xuanze == '注册帐号':
-      zhucezhanghao()
- ########测试人员用
- def ceshiyong():
-     a  = ['借料','报废','快递转仓','转账','查询挂账情况']
-     gongneng = g.choicebox(msg='请选择你所需要的功能.', title='测试人员菜单 ', choices=a)
-     if gongneng  == '借料':
-         print('借料')
-     if gongneng == '报废':
-         print('报废功能')
-     if gongneng == '快递转仓':
-         print('转仓功能')
-     if  gongneng == '转账':
-         print('转账功能')
-     else:
-         print('查询挂账情况')
- ####################
- kaitouchengxu()
复制代码
仓库管理系统17/7/7
密码可以保存到exl里面了。
- def zhucezhanghao():
- msg = "请认真填写并记录,切记!!!"
- title = "账号中心"
- fieldNames = ["*工号", "真实姓名", "*密码", "*重复密码", "手机号码",'部门','座机','入厂日期']
- fieldValues = []
- fieldValues = g.multenterbox(msg, title, fieldNames)
- # print(fieldValues)
- while True:
- if fieldValues == None:
- break
- errmsg = ""
- for i in range(len(fieldNames)):
- option = fieldNames[i].strip()
- if fieldValues[i].strip() == "" and option[0] == "*":
- errmsg += ("【%s】为必填项 " % fieldNames[i])
- if fieldValues[2] != fieldValues[3]:
- g.msgbox('两次密码输入不一致')
- zhucezhanghao()
- if errmsg == "":
- g.msgbox('注册成功')
- # 2017年7月7日新增内容
- zhanghao = fieldValues[0]
- mima = fieldValues[2]
- xierumima(zhanghao, mima)
- # 2017年7月7日新增内容
- break
- fieldValues = g.multenterbox(errmsg, title, fieldNames, fieldValues)
复制代码- def xierumima(zhanghao,mima):
- import xlutils, xlrd, xlwt
- from xlutils.copy import copy
- from openpyxl import load_workbook
- # 2017年7月7日新增内容
- # 打开路径
- oldWb = xlrd.open_workbook('密码.xls', formatting_info=True)
- # 复制
- newWb = copy(oldWb)
- # 工作薄
- newWs = newWb.get_sheet(0)
- ########################################
- # 判断是否为空
- num = 0
- table = oldWb.sheets()[0]
- num = int(table.cell(6,1).value) # 获取特定单元格内容
- num = num + 1
- #写入
- newWs.write(0,num,zhanghao )
- newWs.write(1,num,mima)
- newWs.write(6,1,num)
- # 保存
- newWb.save('密码.xls')
- # 2017年7月7日新增内容
复制代码
仓库管理系统17/7/9
密码可以跟exl里面的数据进行对比。
- #密码与xls进行匹配,2017年7月9日新增内容
- import xlrd
- data = xlrd.open_workbook('密码.xls')
- table = data.sheets()[0]
- i = 0
- user = table.row_values(i)
- password = table.row_values(i + 1)
- print(user,password)
- #密码与xls进行匹配,2017年7月9日新增内容
复制代码 |
评分
-
查看全部评分
|