gpt4 book ai didi

python - 索引 sorteddict 的 ValuesView

转载 作者:太空宇宙 更新时间:2023-11-04 01:34:13 29 4
gpt4 key购买 nike

鉴于 documentation ,以下代码有什么问题:

import blist
d = blist.sorteddict({3: "first", 7: "second"})
print(d.keys()[1])
print(d.values()[1])
print(d.items()[1])

打印

Traceback (most recent call last):
File "test.py", line 4, in <module>
print(d.values()[1])
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/_sorteddict.py", line 53, in __getitem__
key = self._mapping.sortedkeys[index]
AttributeError: 'sorteddict' object has no attribute 'sortedkeys'

最佳答案

这似乎是一个错误。代码没问题。

关于python - 索引 sorteddict 的 ValuesView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11285312/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com