Skip to content

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

@zi-fei-yu-2020

Description

@zi-fei-yu-2020

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions