共计 823 个字符,预计需要花费 3 分钟才能阅读完成。
download: 机器学习中的概率统计利用实际 mk
employee_1 = {‘name’: ‘david’, ‘dept’: ‘ops’, ‘post’: ‘NOC’, ‘salary’: 12000, ‘id’: 113}
employee_2 = {‘name’: ‘brain’, ‘dept’: ‘auto’, ‘post’: ‘DBA’, ‘salary’: 13000, ‘id’: 115}
employee_3 = {‘name’: ‘chris’, ‘dept’: ‘search’, ‘post’: ‘PJM’, ‘salary’: 20000, ‘id’: 150}
employees = [employee_1, employee_2, employee_3]
for employee in employees:
employee['salary'] = employee['salary'] + 1000
print(employee['salary'])
复制代码
输入
View Code
字典中嵌套列表
favorite_thing = {‘foods’: ‘cheese’, ‘drinks’: [‘milk’, ‘juice’, ‘whisky’]}
for drink in favorite_thing[‘drinks’]:
print("I love" + drink)
输入
View Code
字典嵌套列表
复制代码
favorite_language = {‘brain’: [‘python’], ‘chris’: [‘c’, ‘ruby’], ‘david’: [‘power shell’], ‘tina’: [‘shell’, ‘go’, ‘c++’]}
for name, languages in favorite_language.items():
print("\n" + name.title() + "like programing language:")
for language in languages:
print(language.title())
复制代码
输入
View Code
正文完