資源簡介
不要積分的哦 ^ - ^
代碼片段和文件信息
import?json#把字符串類型的數據轉換成Python基本數據類型或者將Python基本數據類型轉換成字符串類型。?
def?login_user():
?while?True:
??register=input(‘用戶姓名:‘)
??try:
???with?open(register+‘.json‘)as?file_object:
????user_message=json.load(file_object)#json.load(obj)?讀取文件中的字符串,序列化成Python的基本數據類型
??except?FileNotFoundError:
???print(‘該用戶不存在!‘)
???break
??else:
???print(‘_‘*20)
???register_password?=?input(‘請輸入密碼:‘)
???if?user_message[‘id‘]==register?and?user_message[‘password‘]==register_password:
????str_print?=?‘姓名:{}\t數學成績:{}\t語文成績:{}\t英語成績:?{}‘
????grade_list?=?[]
????while?1:
?????print(‘‘‘******************************
???????歡迎使用【學生信息管理系統】
???????請選擇你想要進行的操作
???????1.新建學生信息
???????2.顯示全部信息
???????3.查詢學生信息
???????4.刪除學生信息
???????5.修改學生信息
???????0.退出系統
?????******************************‘‘‘)
?????action?=?input(‘請選擇你想要的進行操作:\n‘)
?
?????if?action?==?‘1‘:
??????‘‘‘新建學生信息‘‘‘
??????name?=?input(‘請輸入名字‘)
??????math?=?input(‘請輸入數學成績‘)
??????chinese?=?input(‘請輸入語文成績‘)
??????english?=?input(‘請輸入英語成績‘)
??????total?=?int(math)?+?int(chinese)?+?int(english)
??????grade_list.append([namemathchineseenglishtotal])
??????print([namemathchineseenglishtotal])
??????print(‘姓名:{}\t數學成績:{}\t語文成績:{}\t英語成績:?{}‘.format(namemathchineseenglishtotal))
??????pass
?????elif?action?==?‘2‘:
??????‘‘‘顯示全部信息‘‘‘
??????for?info?in?grade_list:
???????print(str_print.format(*info))
?????elif?action?==?‘3‘:
??????‘‘‘查詢學生信息‘‘‘
??????name?=?input(‘請輸入你需要查詢學生的姓名:‘)
??????for?info?in?grade_list:
???????if?name?in?info:
????????print(str_print.format(*info))
????????break
???????else:
????????print(‘此學生不存在‘)
??????
?????elif?action?==?‘4‘:
??????‘‘‘刪除學生信息‘‘‘
??????name?=?input(‘請輸入你需要查詢學生的姓名:‘)
??????for?info?in?grade_list:
???????if?name?in?info:
????????info_=grade_list.pop(grade_list.index(info))
????????pr
- 上一篇:神經網絡gcn代碼
- 下一篇:自動截屏工具(python源碼)
評論
共有 條評論