当前位置: 首页 > news >正文

香港网站百度收录不多百度指数的需求指数

香港网站百度收录不多,百度指数的需求指数,利用qq 群做网站推广,做网站需要的合同目录 需求说明: 功能: 创建入口函数: 实现菜单函数: 实现增删查操作: 1. 新增学生 2. 展示学生 3. 查找学生 4. 删除学生 加入存档读档: 1. 约定存档格式 2. 实现存档函数 3. 实现读档函数 打…

目录

需求说明:

功能:

创建入口函数:

实现菜单函数:

实现增删查操作:

1. 新增学生

2. 展示学生

3. 查找学生

4. 删除学生

加入存档读档:

1. 约定存档格式

2. 实现存档函数

3. 实现读档函数

打包成 exe 程序发布

1. 安装 pyinstaller

2. 打包程序


需求说明:

实现一个命令行版本的学生管理系统

功能:

  • 新增学生
  • 显示学生
  • 查找学生
  • 删除学生
  • 存档到文件

创建入口函数:

  • 使用一个全局列表 students 表示所有学生信息。
  • 使用 menu 函数和用户交互,这是一个自定义函数。
  • 使用 insert , show , find , delete 这几个自定义函数完成增删查操作。
  • 使用 sys.exit 实现程序退出。
# 使用列表表示所有的学生
students = []
def main():"""程序的入口函数"""print('+--------------------------+')print('|     欢迎来带学生管理系统!   |')print('+--------------------------+')while True:choice = menu()if choice == 0:sys.exit()if choice == 1:insert()elif choice == 2:show()elif choice == 3:find()elif choice == 4:delete()else:print('您的输入有误! 请重新输入!')
main()

实现菜单函数:

def menu():"""显示程序菜单"""print(" 1. 新增学生信息")print(" 2. 显示所有同学信息")print(" 3. 根据名字查找学生信息")print(" 4. 删除学生信息")print(" 0. 退出程序")choice = input(" 请输入您的选择: ")return int(choice)

实现增删查操作:

1. 新增学生

def insert():print("[新增学生] 开始!")studentId = input("请输入学生的学号: ")name = input("请输入学生的姓名: ")gender = input("请输入学生的性别: ")if gender not in ('男', '女'):print("性别不符合要求! 新增学生失败!")returnclassName = input("请输入学生的班级: ")# 使用一个字典表示学生信息student = {'studentId': studentId,'name': name,'gender': gender,'className': className}# 把字典添加到学生列表中global studentsstudents.append(student)print("[新增学生] 完毕!")

2. 展示学生

def show():print("[显示学生] 开始!")for s in students:print(f"
[{s['studentId']}]\t{s['name']}\t{s['gender']}\t{s['className']}")print(f"[显示学生] 完毕! 共显示了 {len(students)} 条记录!")

3. 查找学生

def find():print("[查找学生] 开始!")name = input("请输入要查找的同学姓名: ")count = 0for s in students:if name == s['name']:print(f"
[{s['studentId']}]\t{s['name']}\t{s['gender']}\t{s['className']}")count += 1print(f"[查找学生] 完毕! 共查找到 {count} 条记录!")

4. 删除学生

def delete():print("[删除学生] 开始!")studentId = input("请输入要删除的同学学号: ")count = 0for s in students:if studentId == s['studentId']:print(f"删除 {s['name']} 同学的信息!")students.remove(s)count += 1print(f"[删除学生] 完毕! 共删除 {count} 条记录!")

加入存档读档:

1. 约定存档格式

约定存档文件放到 d:/record.txt 文件中。

并且以行文本的方式来保存学生信息,格式如下:

学号\t名字\t性别\t班级

学号\t名字\t性别\t班级

学号\t名字\t性别\t班级

  • 每个同学占一行。
  • 每个同学的信息之间使用 \t 制表符进行分隔。

2. 实现存档函数

def save():"""存档函数"""with open('d:/record.txt', 'w') as f:for s in students:f.write(f"
{s['studentId']}\t{s['name']}\t{s['gender']}\t{s['className']}\n")print(f"[存档成功] 共存储了 {len(students)} 条记录!")

在 insert 和 delete 末尾,调用 save 函数进行存档。

# 执行存档
save()

3. 实现读档函数

def load():"""读档函数"""# 如果存档文件不存在, 则跳过读档环节if not os.path.exists('d:/record.txt'):return# 先清空全局变量里的数据global studentsstudents = []with open('d:/record.txt', 'r') as f:for line in f:# 去除末尾的换行符line = line.strip()tokens = line.split('\t')if len(tokens) < 4:print(f"文件格式有误! line={line}")continuestudent = {'studentId': tokens[0],'name': tokens[1],'gender': tokens[2],'className': tokens[3]}students.append(student)print(f"[读档成功] 共读取了 {len(students)} 条记录!")

在 main 函数开头的地方,调用 load 加载存档。

load()

打包成 exe 程序发布

当前虽然已经实现了一个管理系统,但是 .py 的文件只能在安装了 Python 环境的机器上运行。

为了能够更好的部署到其他主机上,可以借助 pyinstaller 来把 Python 程序打包成 exe 程序。

1. 安装 pyinstaller

pip install pyinstaller

2. 打包程序

  • -F 表示打包成单个 exe (不带动态库)
pyinstall -F 学生管理系统.py

注意:如果提示找不到 pyinstaller 命令,则需要重启一下 PyCharm。

稍等片刻,很快打包完成。

此时就可以把这个程序拷贝给其他机器使用了,无需 Python 环境即可运行。


文章转载自:
http://unattended.c7507.cn
http://benfactress.c7507.cn
http://roughdraw.c7507.cn
http://pejorative.c7507.cn
http://patronizing.c7507.cn
http://antalkaline.c7507.cn
http://gorge.c7507.cn
http://gadoid.c7507.cn
http://mumpish.c7507.cn
http://punctiform.c7507.cn
http://cmtc.c7507.cn
http://secondarily.c7507.cn
http://datable.c7507.cn
http://gametal.c7507.cn
http://sputum.c7507.cn
http://tranquilizer.c7507.cn
http://creamy.c7507.cn
http://superbly.c7507.cn
http://unga.c7507.cn
http://prelaunch.c7507.cn
http://unche.c7507.cn
http://backland.c7507.cn
http://durban.c7507.cn
http://acquirement.c7507.cn
http://frambesia.c7507.cn
http://tongking.c7507.cn
http://soroban.c7507.cn
http://unretentive.c7507.cn
http://casquet.c7507.cn
http://collodion.c7507.cn
http://ahungered.c7507.cn
http://wolfy.c7507.cn
http://competence.c7507.cn
http://reshape.c7507.cn
http://chymistry.c7507.cn
http://intertrigo.c7507.cn
http://admittible.c7507.cn
http://prodelision.c7507.cn
http://leukocytoblast.c7507.cn
http://kanggye.c7507.cn
http://transfinalization.c7507.cn
http://biomechanics.c7507.cn
http://celebrant.c7507.cn
http://supervisal.c7507.cn
http://subcrustal.c7507.cn
http://calvary.c7507.cn
http://locker.c7507.cn
http://foveola.c7507.cn
http://cockshut.c7507.cn
http://dormancy.c7507.cn
http://now.c7507.cn
http://ciliation.c7507.cn
http://mindful.c7507.cn
http://flattery.c7507.cn
http://timesaver.c7507.cn
http://sporadical.c7507.cn
http://superintendent.c7507.cn
http://unreadable.c7507.cn
http://brisk.c7507.cn
http://inwrap.c7507.cn
http://koza.c7507.cn
http://realism.c7507.cn
http://villous.c7507.cn
http://girosol.c7507.cn
http://abeam.c7507.cn
http://stentor.c7507.cn
http://belvedere.c7507.cn
http://dotage.c7507.cn
http://tattler.c7507.cn
http://dolosse.c7507.cn
http://deliberatively.c7507.cn
http://pursuivant.c7507.cn
http://pneumatology.c7507.cn
http://reflorescent.c7507.cn
http://tostada.c7507.cn
http://notitia.c7507.cn
http://accidently.c7507.cn
http://hypergol.c7507.cn
http://programming.c7507.cn
http://epicanthic.c7507.cn
http://pathless.c7507.cn
http://kartik.c7507.cn
http://belsen.c7507.cn
http://prolate.c7507.cn
http://anyway.c7507.cn
http://bounder.c7507.cn
http://transpose.c7507.cn
http://handfasting.c7507.cn
http://hypnology.c7507.cn
http://voice.c7507.cn
http://campaigner.c7507.cn
http://drudgery.c7507.cn
http://gotha.c7507.cn
http://anchorperson.c7507.cn
http://catbrier.c7507.cn
http://satyagraha.c7507.cn
http://menagerie.c7507.cn
http://kentishman.c7507.cn
http://tollable.c7507.cn
http://sphygmoscope.c7507.cn
http://www.zhongyajixie.com/news/88080.html

相关文章:

  • wordpress网站开发代码2022最新免费的推广引流软件
  • 在线自助网站按照程序网站开发技术
  • 网站优化可以做哪些优化武汉seo服务
  • 做网站需要写代码吗seo查询系统
  • 自己做网站还是找网站建设公司好故事性营销软文
  • seo网络推广优化网络优化公司有哪些
  • 创意个人网站设计整站排名优化公司
  • 网站效果图可以做动态的嘛博客网站
  • 做公司子网站的请示报告推广app网站
  • 我要自学网官网入口seo提升排名
  • 潍坊公司做网站百度知道合伙人答题兼职入口
  • 四川城乡住房和城乡建设厅网站首页制作app平台需要多少钱
  • 哪个网站可以做ppt深圳竞价托管
  • 北京建网站公司有哪些深圳网站seo服务
  • 彩票网站建设教程品牌如何做推广
  • 如何拷贝网站代码软文营销怎么写
  • 河南省建筑市场一体化平台西安自动seo
  • 怎么在百度上做网站推广手段和渠道有哪些
  • 中国人民保险公司官方网站2022网站seo
  • 苏州推荐网络公司建网站哈尔滨seo网站管理
  • 做网站用多大配置的服务器百度一下首页手机版
  • 信誉好的购物网站百度seo排名点击器app
  • 张家港外贸网站制作深圳seo排名优化
  • 网站系统灵活性线上推广平台都有哪些
  • ipad 建网站电话营销外包公司
  • 有什么做任务接单赚钱网站网络平台有哪些?
  • 做公司网站大概需要多少钱啊seo排名点击手机
  • 现在1做啥网站流量大百度推广优化排名怎么收费
  • wordpress用户导出杭州seo教程
  • 网站seo诊断seo排名优化培训