AttributeError: module '__main__' has no attribute 'main'解决方法

在终端运行.py文件时报错:AttributeError: module '__main__' has no attribute 'main'

原因:在PyCharm里运行python程序需要添加

if __name__ == "__main__":

但是直接用python命令行运行时无法识别出该函数头,删除该函数所有内容即可!

posted @ 2019-01-04 18:32  codeg  阅读(8840)  评论(0编辑  收藏  举报