面向 MATLAB 用户的 Python
Justin Kiggins
Product Manager
type(definitions)
dict
print(definitions['aardvark'])
A nocturnal burrowing mammal with long ears, a tubular snout, and a long
extensible tongue, feeding on ants and termites. Aardvarks are native to
Africa and have no close relatives.
# 创建字典
dog = {'name': 'Toby', 'breed': 'Basset Hound'}
# 添加更多键:值
dog['weight (lbs)'] = 552.3
dog['birthdate'] = "2016-06-26"
print(dog)
{'name': 'Toby',
'breed': 'Basset Hound',
'weight (lbs)': 552.3,
'birthdate': '2016-06-26'}
# 更新体重值 dog['weight (lbs)'] = 52.3print(dog)
{'name': 'Toby',
'breed': 'Basset Hound',
'weight (lbs)': 52.3,
'birthdate': '2016-06-26'}
dog.pop('birthdate')
print(dog)
{'name': 'Toby',
'breed': 'Basset Hound',
'weight (lbs)': 52.3}
面向 MATLAB 用户的 Python