gpt4 book ai didi

python - 为什么 PyCharm 建议我将列表转换为集合?

转载 作者:太空宇宙 更新时间:2023-11-03 10:59:47 26 4
gpt4 key购买 nike

构建了以下列表:

NO_VACANCIES = ['no vacancies', 
'not hiring',
'no open positions',
'all positions are currently filled'
'no positions are available'
"don't have any vacancies"
"we don't have any jobs available"
"we don't have any positions available"
'no positions are currently available']

... PyCharm 建议我将其转换为 set,但没有给出任何理由:

enter image description here

这种转换可能有什么好处?

最佳答案

您显示的菜单不是建议;它是一种工具(称为“意图行动”)。如果您决定需要一个集合而不是一个列表,您可以将此列表更改为一个集合。它并没有告诉您这个列表应该是一个集合,或者集合通常在某种程度上更好。

关于python - 为什么 PyCharm 建议我将列表转换为集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35181153/

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