Êéͨѧϰ·½·¨Íø -°üº¬Ð¡Ñ§¡¢³õÖС¢Öп¼¡¢¸ßÖС¢¸ß¿¼µÈ¸÷ÖÖѧϰ·½·¨¡£
ÊéͨÍølogo
µ±Ç°Î»ÖÃ: ÊéͨÍø > ѧϰ·½·¨ > ѧÉú¹ÜÀíÐÅϢϵͳ£¨¼òÒ×°æѧÉúÐÅÏ¢¹ÜÀíϵͳ£©

ѧÉú¹ÜÀíÐÅϢϵͳ£¨¼òÒ×°æѧÉúÐÅÏ¢¹ÜÀíϵͳ£©

ʱ¼ä:2023-02-22 ·ÖÀà:ѧϰ·½·¨ À´Ô´:ÊéͨÍø

Ö÷Òª¹¦ÄÜ£º

Ìí¼ÓѧÉúÐÅϢɾ³ýѧÉúÐÅÏ¢ÐÞ¸ÄѧÉúÐÅÏ¢²éѯѧÉúÐÅÏ¢ÏÔʾѧÉúÐÅÏ¢Í˳öµ±Ç°ÏµÍ³

²½Öè·ÖÎö£º

ÏÔʾ¹¦ÄܽçÃæÓû§ÊäÈ빦ÄÜÐòºÅ¶Ô²»Í¬ÐòºÅµÄ¹¦ÄÜʵÏÖ¾ßÌ庯Êý ¶¨Ò庯Êý µ÷Óú¯Êý

ÐèÇóʵÏÖ£º

ÏÔʾ¹¦ÄܽçÃæ home()Óû§ÊäÈ빦ÄÜÐòºÅ user_num = int(input("ÇëÊäÈëÑ¡Ï"))°´ÕÕÓû§ÊäÈëµÄ¹¦ÄÜÐòºÅ£¬Ö´Ðв»Í¬µÄ¹¦ÄÜ(º¯Êý)Ìí¼ÓѧÉúÐÅÏ¢ add_info()ɾ³ýѧÉúÐÅÏ¢ del_info()ÐÞ¸ÄѧÉúÐÅÏ¢ modify_info()²éѯѧÉúÐÅÏ¢ search_info()ÏÔʾѧÉúÐÅÏ¢ print_all()

¾ßÌåʵÏÖ£º

"""Ö÷½çÃæ"""

def home():

print("--------ÇëÑ¡Ôñ¹¦ÄÜ--------")

print("1.Ìí¼ÓѧÉúÐÅÏ¢")

print("2.ɾ³ýѧÉúÐÅÏ¢")

print("3.ÐÞ¸ÄѧÉúÐÅÏ¢")

print("4.²éѯѧÉúÐÅÏ¢")

print("5.ÏÔʾѧÉúÐÅÏ¢")

print("6.Í˳öµ±Ç°ÏµÍ³")

print("-" * 20)

# ¶¨ÒåѧÉúÐÅÏ¢Áбí

stu_info = ]

"""Ìí¼ÓѧÉúÐÅÏ¢º¯Êý"""

def add_info():

# 1 Óû§ÊäÈë ѧºÅ ÐÕÃû ÄêÁä ÐÔ±ð ÊÖ»úºÅ

stu_id = input("ÊäÈëѧºÅ£º")

stu_name = input("ÊäÈëÐÕÃû£º")

stu_age = input("ÊäÈëÄêÁ䣺")

stu_gender = input("ÊäÈëÐÔ±ð£º")

stu_phone = input("ÊäÈëÊÖ»úºÅ£º")

global stu_info

# 2 ÅжÏÊÇ·ñÌí¼ÓÕâ¸öѧÉú£¬²»ÔÊÐíÖØÃû£¬Èç¹ûѧÉúÐÕÃûÒÑ´æÔÚÌáʾ£¬Èç¹û²»´æÔÚÔòÌí¼ÓÊý¾Ý

for i in stu_info:

if stu_name == i'name']:

print("´ËѧÉúÐÅÏ¢ÒÑ´æÔÚ£¬ÇëÎðÖظ´Ìí¼Ó")

return

# Èç¹ûÓû§ÊäÈëµÄÐÕÃû²»´æÔÚ£¬ÔòÌí¼Ó¸ÃѧÉúÐÅÏ¢

info_dict = {'id': stu_id, 'name': stu_name, 'age':

stu_age, 'gender': stu_gender, 'phone': stu_phone}

stu_info.append(info_dict)

print("Ìí¼Ó³É¹¦")

print(stu_info)

"""ɾ³ýѧÉúÐÅÏ¢º¯Êý"""

def del_info():

# 1 Óû§ÊäÈëҪɾ³ýµÄѧÉúµÄÐÕÃû

del_name = input("ÇëÊäÈëҪɾ³ýµÄѧÉúµÄÐÕÃû£º")

global stu_info

# 2 ÅжÏѧÉúÊÇ·ñ´æÔÚ ´æÔÚÔòÖ´ÐÐɾ³ýÐÅÏ¢£¬²»´æÔÚÔòÌáʾ

for i in stu_info:

if del_name == i'name']:

stu_info.remove(i)

print("ÒÑɾ³ý")

break

else:

print("¸ÃѧÉú²»´æÔÚ")

print(stu_info)

"""ÐÞ¸ÄѧÉúÐÅÏ¢º¯Êý"""

def modify_info():

# 1 ÊäÈëÒªÐ޸ĵÄѧÉúµÄÐÕÃû

modify_name = input("ÇëÊäÈëÒªÐ޸ĵÄѧÉúµÄÐÕÃû£º")

global stu_info

# 2 ÅжÏѧÉúÊÇ·ñ´æÔÚ£¬Èç¹û´æÔÚÔòÐÞ¸ÄÊÖ»úºÅ£¬·ñÔòÔòÌáʾ

for i in stu_info:

if modify_name == i'name']:

i'phone'] = input("ÇëÊäÈëеÄÊÖ»úºÅ£º")

print("ÒÑÐÞ¸Ä")

break

else:

print("¸ÃѧÉú²»´æÔÚ")

print(stu_info)

"""²éѯѧÉúÐÅÏ¢º¯Êý"""

def search_info():

# 1 ÊäÈëÒª²éÕÒµÄѧÉúÐÕÃû

search_name = input("ÇëÊäÈëÒª²éÕÒµÄѧÉúÐÕÃû£º")

global stu_info

# 2 ÅжÏѧÉúÊÇ·ñ´æÔÚ£¬Èç¹û´æÔÚÔòÏÔʾ¸ÃѧÉúÐÅÏ¢£¬·ñÔòÔòÌáʾ

for i in stu_info:

if search_name == i'name']:

print("ÕÒµ½¸ÃѧÉúµÄÐÅÏ¢ÈçÏ£º")

print(f"¸ÃѧÉúµÄѧºÅÊÇ{i'id']},ÐÕÃûÊÇ{i'name']},ÄêÁäÊÇ{i'age']},ÐÔ±ðÊÇ{i'gender']},ÊÖ»úºÅÊÇ{i'phone']}")

break

else:

print("¸ÃѧÉú²»´æÔÚ")

"""ÏÔʾѧÉúÐÅÏ¢"""

def print_all():

print("ѧºÅ\tÐÕÃû\tÄêÁä\tÐÔ±ð\tÊÖ»úºÅ")

for i in stu_info:

print(f"{i'id']}\t{i'name']}\t{i'age']}\t{i'gender']}\t{i'phone']}")

def main():

while True:

# 1.ÏÔʾ¹¦ÄܽçÃæ

home()

# 2.Óû§ÊäÈ빦ÄÜÐòºÅ

user_num = int(input("ÇëÊäÈëÑ¡Ï"))

# 3.°´ÕÕÓû§ÊäÈëµÄ¹¦ÄÜÐòºÅ£¬Ö´Ðв»Í¬µÄ¹¦ÄÜ(º¯Êý)

# Èç¹ûÊäÈë1£¬Ö´ÐÐÌí¼ÓѧÉúµÄ¹¦ÄÜ

if user_num == 1:

add_info()

# Èç¹ûÊäÈë2£¬Ö´ÐÐɾ³ýѧÉúµÄ¹¦ÄÜ

elif user_num == 2:

del_info()

# Èç¹ûÊäÈë3£¬Ö´ÐÐÐÞ¸ÄѧÉúµÄ¹¦ÄÜ

elif user_num == 3:

modify_info()

# Èç¹ûÊäÈë4£¬Ö´ÐвéѯѧÉúµÄ¹¦ÄÜ

elif user_num == 4:

search_info()

# Èç¹ûÊäÈë5£¬Ö´ÐÐÏÔʾѧÉúµÄ¹¦ÄÜ

elif user_num == 5:

print_all()

# Èç¹ûÊäÈë6£¬È·ÈÏÊÇ·ñÍ˳ö Ö´ÐÐÍ˳öϵͳ

elif user_num == 6:

exit_flag = input("È·¶¨ÒªÍ˳öÂð£¿yes/no")

if exit_flag == "yes":

break

else:

print("ÊäÈëÓÐÎó£¡ÇëÖØÐÂÊäÈë")

if __name__ == '__main__':

main()

ÔËÐÐЧ¹û£º

Ìí¼ÓºÍɾ³ýѧÉúÐÅÏ¢

Ð޸ĺͲéѯѧÉúÐÅÏ¢

ÏÔʾËùÓÐѧÉúÐÅÏ¢ºÍÍ˳öϵͳ

С±àÍƼö£º ×ۺϹÜÀí²¿¸ÚλְÔð£¨Ñ§Éú¹ÜÀí¸ÚλְÔð·Ö¹¤£©°²È«Éú²úÐÅÏ¢»¯¹ÜÀíƽ̨app£¨Çɲ顰СÒþ»¼¡±Ó®µÃ¡°´ó°²È«¡±£©ÈçºÎÌá¸ßѧÉúµÄ×¢ÒâÁ¦

ÍƼöÔĶÁ