标签:alt dict learning python lte nan span balance 嵌套
Dataset = { ‘Equity Fund‘: ‘Deep value‘, ‘Balanced Fund‘: ‘Market oriented with a growth bias‘, ‘Fixed Income Fund‘: [‘Government bond‘,‘Financial Notes‘,‘Credit Bond‘,‘MBS‘], }
print(Dataset)
{‘Equity Fund‘: ‘Deep value‘, ‘Balanced Fund‘: ‘Market oriented with a growth bias‘, ‘Fixed Income Fund‘: [‘Government bond‘, ‘Financial Notes‘, ‘Credit Bond‘, ‘MBS‘]}
Dataset["Alternative Investment"] = ‘REITS‘ # 添加Key
print(Dataset)
{‘Equity Fund‘: ‘Deep value‘, ‘Balanced Fund‘: ‘Market oriented with a growth bias‘, ‘Fixed Income Fund‘: [‘Government bond‘, ‘Financial Notes‘, ‘Credit Bond‘, ‘MBS‘], ‘Alternative Investment‘: ‘REITS‘}
Dataset["Equity Fund"] = ‘Fundamental Growth‘
Dataset[‘Fixed Income Fund‘][1] = ‘MTN‘
print(Dataset)
{‘Equity Fund‘: ‘Fundamental Growth‘, ‘Balanced Fund‘: ‘Market oriented with a growth bias‘, ‘Fixed Income Fund‘: [‘Government bond‘, ‘MTN‘, ‘Credit Bond‘, ‘MBS‘], ‘Alternative Investment‘: ‘REITS‘}
del Dataset[‘Equity Fund‘] print(Dataset)
or
Dataset.pop("Equity Fund") print(Dataset)
or 随机删除
Dataset.popitem()
查找
Python 基础 - Day 2 Learning Note - Dictionary 字典
标签:alt dict learning python lte nan span balance 嵌套
原文地址:http://www.cnblogs.com/lg100lg100/p/7082239.html