错误记录PyCharm 运行 Python 程序报错 ( PEP 8: E402 module level import not at top of file )

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误记录PyCharm 运行 Python 程序报错 ( PEP 8: E402 module level import not at top of file )相关的知识,希望对你有一定的参考价值。





一、报错信息



PyCharm 运行 Python 程序报错 :

PEP 8: E402 module level import not at top of file

详细的报错截图 :





二、解决方案



导入模块 , 必须写在 Python 代码的非注释 的前 n n n 行 , 其它代码 , 不能放在导入模块的代码前面 ;

按照上述要求 , 将导入模块的代码 , 放在前面几行 , 在导入模块完毕后 , 才能写其它代码 ;

修改完后 , 报错消失 ;

以上是关于错误记录PyCharm 运行 Python 程序报错 ( PEP 8: E402 module level import not at top of file )的主要内容,如果未能解决你的问题,请参考以下文章