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

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

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

if __name__ == "__main__":

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

猜你喜欢

转载自www.cnblogs.com/darklights/p/10221814.html