目录
常见错误
忽略警告(不推荐)
依次选择 File - Settings - Editor - Inspections,在 Python下找到 PEP8 coding style violation 选项,在右下角的 Ignore errors 里点击加号可以添加需要忽略的警告信息ID(ID信息见后面附录),例如想要忽略indentation contains mixed spaces and tabs
这个警告,只需要添加其ID:E101 即可
全部警告信息以及对应的ID,官方地址:https://pep8.readthedocs.io/en/latest/intro.html#error-codes
pycharm pep8快捷键
Ctrl+Alt+L
pycharm 设置autopep8修正
比pycharm内置的更规范,功能更强大
- 安装autopep8:pip install autopep8
- 内容如下:
autopep8
--in-place --aggressive --aggressive $FilePath$
$ProjectFileDir$
$FILE_PATH$\:$LINE$\:$COLUMN$\:.*