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.
studentList = [ [ " tsy " , " 男 " , " 123 " ] ]
tempList = [ ]
def add_student ( ) :
temp = [ ]
initList ( )
name = input ( " 请输入姓名: " )
if search_user ( name ) != - 1 :
print ( " 用户已存在 " )
return
sex = input ( " 请输入性别: " )
phone = input ( " 请输入电话: " )
temp . append ( name )
temp . append ( sex )
temp . append ( phone )
tempList . append ( temp )
def del_user ( name ) :
initList ( )
if search_user ( name ) == - 1 :
print ( " 未找到此用户 " )
return
tempList . remove ( tempList [ search_user ( name ) ] )
def search_user ( name ) :
for i in range ( len ( studentList ) ) :
if studentList [ i ] [ 0 ] == name :
return i
else :
return - 1
def update_user ( ) :
initList ( )
temp = [ ]
name = input ( " 请输入姓名: " )
if search_user ( name ) == - 1 :
print ( " 未找到此用户 " )
return
sex = input ( " 请输入性别: " )
phone = input ( " 请输入电话: " )
temp . append ( name )
temp . append ( sex )
temp . append ( phone )
tempList [ search_user ( name ) ] = temp
def quaryAll ( ) :
return studentList
def saveInfo ( ) :
studentList . clear ( )
studentList . extend ( tempList )
tempList . clear ( )
print ( " 操作已保存 " )
def initList ( ) :
tempList . clear ( )
tempList . extend ( studentList )
def init ( ) :
print ( " 请选择如下功能 \n 1: 添加学员 \n 2: 删除 \n 3: 修改该学员 \n 4: 查询学员 \n 5: 显示所有学员 \n 6: 保存学员信息 \n 7: 退出 " )
action = int ( input ( " 请输入您需要的功能序号: " ) )
while action != 7 :
if action == 1 :
add_student ( )
elif action == 2 :
name = input ( " 输入要删除的学生姓名: " )
del_user ( name )
elif action == 3 :
update_user ( )
elif action == 4 :
name = input ( " 输入要查询的学生姓名: " )
res = studentList [ search_user ( name ) ] if search_user ( name ) != - 1 else " 未找到 "
print ( res )
elif action == 5 :
print ( quaryAll ( ) )
elif action == 6 :
saveInfo ( )
action = int ( input ( " 请输入您需要的功能序号: " ) )
if __name__ == ' __main__ ' :
init ( )