gpt4 book ai didi

python - 为什么 Python2 到 Python3 转换器将 "items()"放入 "list"?

转载 作者:太空宇宙 更新时间:2023-11-04 08:37:11 25 4
gpt4 key购买 nike

<分区>

我使用一种工具将我的代码从 Python2 重新格式化为 Python3。它总是做的一件事是替换

my_dict.items()

通过

list(my_dict.items())

背后的动机是什么?我假设 items() 不保证排序(它是随机的,因为字典没有排序)。因此,通过使用 list,我们对 key, value 对进行排序。

我的假设是否正确?

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