Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.字典推导式中有错误 #93

Open
zi-fei-yu-2020 opened this issue Feb 10, 2023 · 1 comment
Open

6.字典推导式中有错误 #93

zi-fei-yu-2020 opened this issue Feb 10, 2023 · 1 comment

Comments

@zi-fei-yu-2020
Copy link

字典这个是一个迭代器对象,参考官方文档找到下列说明,字典只支持Key的遍历,,如果想对key,value,则可以使用items方法,原代码:d = {key: value for (key, value) in iterable}报错,所以正确的代码应该是d = {key: value for (key, value) in iterable.items()}

@Qvil85
Copy link

Qvil85 commented Feb 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants