students = [ {"name": "阿土", "age": 20, "gender": True, "height": 1.7, "weight": 75.0}, {"name": "小美", "age": 19, "gender": False, "height": 1.6, "weight": 45.0}, ] find_name = "阿土" for stu_dict in students: print(stu_dict) # 判断当前遍历的字典中姓名是否为find_name if stu_dict["name"] == find_name: print("找到了") break else: print("没有找到") print("循环结束")
Python——对比列表里的字典和你查找的是否相同
最新推荐文章于 2024-05-17 07:27:50 发布