最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python學(xué)生管理系統(tǒng)示例

import os

婁星ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

stus = [] # 學(xué)生信息列表(每個學(xué)生的信息以字段存儲)

def add_stu():
sid = input('輸入學(xué)生學(xué)號:')
sname = input('輸入學(xué)生姓名:')
sage = input('輸入學(xué)生年齡:')
dict_stu = {'id': sid.strip(), 'name': sname.strip(), 'age': int(sage.strip())}
stus.append(dict_stu)

def remove_stu(name):
item = search_stu(name)
stus.remove(item)

def search_stu(name):
flag = False
for s in stus:
if s['name'] == name.strip():
print(s)
flag = True
return s
if flag == False:
print('該學(xué)生不存在')
return None

def query_all_stu():
print('序號\tid\tname\tage')
for i, stu in enumerate(stus, 1):
print(i, end="")
print('\t%s\t%s\t%s' % (stu['id'], stu['name'], stu['age']))

def print_menu():
print('=' * 30)
print('學(xué)生管理系統(tǒng)'.center(30))
print('輸入1:添加學(xué)生')
print('輸入2:查找學(xué)生')
print('輸入3:修改學(xué)生')
print('輸入4:刪除學(xué)生')
print('輸入5:查看所有學(xué)生')
print('輸入6:退出')

def file_read():
try:
file_name=r'stu.txt'
if os.path.exists(file_name):
f = open(file_name, 'r', encoding='utf-8')
while True:
line_text = f.readline()
if line_text == "":
break
line_list = line_text.split()
dict_item={'id':line_list[0],'name':line_list[1],'age':line_list[2]}
stus.append(dict_item)
print(line_list)
f.close()
else:
print('file is not exist.')

except Exception as e:
    print(e)
finally:
    print('file_read methon is exec completed.')

def file_write():
try:
file_name = r'stu.txt'
if os.path.exists(file_name):
os.remove(file_name)
f = open(file_name, 'w', encoding='utf-8')
for item in stus:
line_text = "%s\t%s\t%s" % (item['id'], item['name'], item['age'])
f.write(line_text)
f.write('\n')
f.close()

except Exception as e:
    print(e)
finally:
    print('file_write methon exec over..')

def main():
file_read()
while True:
print_menu()
operate = input('請輸入你想要的操作:')
if operate == "1":
add_stu()
elif operate == "2":
sname = input("輸入學(xué)生姓名:")
search_stu(sname)
elif operate == "3":
pass
elif operate == "4":
sname = input("請輸入刪除學(xué)生的姓名:")
remove_stu(sname)
elif operate == "5":
query_all_stu()
else:
file_write()
print('exit......')
break

main()


網(wǎng)頁名稱:Python學(xué)生管理系統(tǒng)示例
文章出自:http://fisionsoft.com.cn/article/popjpi.html