[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>好友管理系统
1、实验题目:好友管理系统
请设计一个好友管理系统,每个功能都对应一个序号,用户可根据提示“请输入您的选项”选择序号执行相应的操作,包括:
(1)添加好友:用户根据提示“请输入要添加的好友:”输入要添加好友的姓名,添加后会提示“好友添加成功”。
(2)删除好友:用户根据提示“请输入删除好友姓名:”输入要删除好友的姓名,删除后提示“删除成功”。
(3)备注好友:用户根据提示“请输入要修改的好友姓名:”和“请输入修改后的好友姓名:”分别输入修改前和修改后的好友姓名,修改后会提示“备注成功”。
(4)展示好友:若用户还没有添加过好友,提示“好友列表为空”,否则返回每个好友的姓名。
(5)退出:关闭好友系统。
list_f = [] print("好友管理系统") print("1.添加好友") print("2.删除好友") print("3.备注好友")
print("4.展示好友") print("5.退出") while True: n = int(input("请输入您的选项:")) if n == 1:
f= input("请输入要添加的好友:") list_f.append(f) print("好友添加成功") elif n == 2: f = input(
"请输入删除好友姓名:") list_f.remove(f) print("删除成功") elif n == 3: o_name = input(
"请输入要修改的好友姓名:") n_name = input("请输入修改后的好友姓名:") i = list_f.index(o_name) list_f[i
] = n_name print("备注成功") elif n == 4: if len(list_f) == 0: print("好友列表为空") else:
for m in list_f: print(m) elif n == 5: break print("关闭好友系统")
重点:
1.建一个空列表存放好友信息。
2.append()添加
3.remove()删除
4.index()索引匹配第一次出现的位置