You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#! python
# -*- coding: UTF-8 -*-
'''
@Author : Star
@Date : 2023/11/21
'''
stu_list = [ [ " 1 " , " 1 " , " 1 " ] ]
temp_list = [ ]
def addStudent ( ) :
temp_list . clear ( )
name = input ( " 请输入您的姓名: " )
if queryS ( name ) :
print ( " 学员已存在 " )
else :
sex = input ( " 请输入您的性别: " )
phone = input ( " 请输入您的电话: " )
stu = [ name , sex , phone ]
temp_list . append ( stu )
def delStudent ( ) :
num = input ( " 请输入删除序号 " )
for i in stu_list :
if i [ 0 ] == num :
stu_list . remove ( i )
print ( stu_list )
def editStudent ( ) :
temp_list . clear ( )
name = input ( " 请输入您的姓名: " )
if queryS ( name ) :
sex = input ( " 请输入您的性别: " )
phone = input ( " 请输入您的电话: " )
stu = [ name , sex , phone ]
temp_list . append ( stu )
# temp_list = stu_list
# for i in temp_list:
# if i[0].find(name) != -1:
# return
print ( stu_list , temp_list )
else :
print ( " 未查询到该学员 " )
# temp_list[i[0].find(name)] = stu
def queryS ( name ) :
for i in stu_list :
if i [ 0 ] . find ( name ) != - 1 :
return True
else :
return False
def queryStudent ( ) :
name = input ( " 请输入查询姓名: " )
for i in stu_list :
if i [ 0 ] . find ( name ) != - 1 :
print ( i )
return
else :
print ( " 未查询到该学员 " )
return
def show ( ) :
print ( stu_list )
def save ( ) :
if len ( temp_list ) > 0 :
for i in stu_list :
print ( i , temp_list )
if i [ 0 ] == temp_list [ 0 ] [ 0 ] :
stu_list . clear ( )
print ( stu_list )
stu_list . append ( temp_list [ 0 ] )
return
else :
stu_list . extend ( temp_list )
return
else :
print ( " 请先执行其他操作 " )
def run ( ) :
while True :
print ( " 请选择如下功能: " )
print ( " 1: 添加 " )
print ( " 2: 删除 " )
print ( " 3: 修改 " )
print ( " 4: 查询 " )
print ( " 5: 显示 " )
print ( " 6: 保存 " )
print ( " 7: 退出 " )
num = input ( " 输入编号: " )
if num == " 1 " :
addStudent ( )
elif num == " 2 " :
delStudent ( )
elif num == " 3 " :
editStudent ( )
elif num == " 4 " :
queryStudent ( )
elif num == " 5 " :
show ( )
elif num == " 6 " :
save ( )
elif num == " 7 " :
show ( )
else :
print ( " 输入无效 " )
if __name__ == ' __main__ ' :
run ( )
# num = input("请输入您需要的功能序号:")
# print(global_stu_array)