PEP8建议:
Imports should be grouped in the following order:
- standard library imports
- related third party imports
- local application/library specific imports
You should put a blank line between each group of imports.
有没有办法使用静态代码分析工具检查包中的任何地方是否违反标准,例如 pylint
、pyflakes
、pychecker
, pep8
?
违规示例:
from my_package import my_module
from django.db import models
import os
正确的导入方式:
import os
from django.db import models
from my_package import my_module
最佳答案
当前版本的 pylint 现在执行此操作,并将其报告为错误类 C0411。
关于python - 进口订单编码标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22722976/