我尝试使用 'in' 和 has_key(),但如果键不是单个值,这些似乎不起作用:
>>> aarr["x","y","z"]=1
>>> aarr["x","y","z"]
1
>>> if "x","y","z" in aarr:
File "<stdin>", line 1
if "x","y","z" in aarr:
^
SyntaxError: invalid syntax
>>> aarr.has_key("x","y","z")
Traceback (most recent call last):
File "<stdin>', line 1, in <module>
TypeError: has_key() takes exactly one argument (3 given)
尝试aarr.has_key(["x","y","z"])
或者如果["x","y","z"] in aarr:
在这两种情况下都抱怨unhashable type: 'list'
.