|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
新手求教:
test_one={
'aa':'11',
'bb':'22',
'cc':'33',
'dd':'44',
'ee':'55'
}
test_two=['bb','dd']
for name in test_one.keys() :
print (name.title())
if test_two in test_one :
print (name + one[name])
为什么会出现:
Aa
Traceback (most recent call last):
File "E:\python库\no2.py", line 12, in <module>
if test_two in test_one :
TypeError: unhashable type: 'list'
的报错,怎么解决,求大神指点
你应该是想这样吧:
- test_one = {
- 'aa': '11',
- 'bb': '22',
- 'cc': '33',
- 'dd': '44',
- 'ee': '55'
- }
- test_two = ['bb', 'dd']
- for name in test_one.keys():
- print(name.title())
- if 'bb' in test_one or 'dd' in test_one:
- print(name + test_one[name])
复制代码
|
|