Skip to content

python: if __name__ == '__main__' #14

@humingcheng

Description

@humingcheng

当在模块内执行时,name == 'main'
当在模块外执行时:name == 'module'
因此该语句用于判断本模块是自己在执行还是被导入执行

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