python字典定义

2024-02-15 17:10:25

```

smart_lights = {

'light': {'brightness': , 'on_off': True},

'light': {'brightness': , 'on_off': False},

#...

}

```

对于在线瑜伽课程定义个字典来表示每节课程的信息,键是课程名称或ID,值则是关于该课程的所有详细信息,如课程时长、难度级别、教师姓名等。

```

yoga_courses = {

'course': {'duration': , 'level': 'beginner', 'instructor': 'John'},

'course': {'duration': , 'level': 'intermediate', 'instructor': 'Jane'},

#...

}

```

房屋租赁信息通过字典进行管理,键为房屋唯标识,值则包含房租、地理位置、是否空闲等信息。

```

rental_properties = {

'property': {'rent': , 'location': 'New York', 'available': True},

'property': {'rent': , 'location': 'Los Angeles', 'available': False},

#...

}

```

在生物制药中使用字典来储存各种药物的相关数据,如药效、副作用、适用人群等。

```

drugs = {

'drug': {'efficacy': 'good', 'side_effects': 'mild', 'for_who': 'adults'},

'drug': {'efficacy': 'excellent', 'side_effects': 'moderate', 'for_who': 'children'},

#...

}

```