用了几天的PyCharm,发现确实在编写Python代码上非常好用,但有一点体验不太好,就是代码编写时要按照PEP8代码风格编写,不然会有波浪线的警告信息。解决方法如下:

方法一:

将鼠标移到提示的地方,按alt+Enter,选择忽略(Ignore)这个错误即好。

方法二

打开:File - Settings…… - Editor - Inspections

在python下找到 PEP8 coding style violation,在右边下面的Ignore errors里可以添加忽略的警告信息ID,如下:

如E302就是忽略“expected 2 blank lines, found 0”这个警告(出现在我想给方法上面添加注释的时候)。


警告信息对应的ID在http://pep8.readthedocs.io/en/latest/intro.html#configuration中可找到。

原文地址


附录如下:

code sample message
E1 Indentation
E101 indentation contains mixed spaces and tabs
E111 indentation is not a multiple of four
E112 expected an indented block
E113 unexpected indentation
E114 indentation is not a multiple of four (comment)
E115 expected an indented block (comment)
E116 unexpected indentation (comment)
E121 (*^) continuation line under-indented for hanging indent
E122 (^) continuation line missing indentation or outdented
E123 (*) closing bracket does not match indentation of opening bracket’s line
E124 (^) closing bracket does not match visual indentation
E125 (^) continuation line with same indent as next logical line
E126 (*^) continuation line over-indented for hanging indent
E127 (^) continuation line over-indented for visual indent
E128 (^) continuation line under-indented for visual indent
E129 (^) visually indented line with same indent as next logical line
E131 (^) continuation line unaligned for hanging indent
E133 (*) closing bracket is missing indentation
E2 Whitespace
E201 whitespace after ‘(‘
E202 whitespace before ‘)’
E203 whitespace before ‘:’
E211 whitespace before ‘(‘
E221 multiple spaces before operator
E222 multiple spaces after operator
E223 tab before operator
E224 tab after operator
E225 missing whitespace around operator
E226 (*) missing whitespace around arithmetic operator
E227 missing whitespace around bitwise or shift operator
E228 missing whitespace around modulo operator
E231 missing whitespace after ‘,’, ‘;’, or ‘:’
E241 (*) multiple spaces after ‘,’
E242 (*) tab after ‘,’
E251 unexpected spaces around keyword / parameter equals
E261 at least two spaces before inline comment
E262 inline comment should start with ‘# ‘
E265 block comment should start with ‘# ‘
E266 too many leading ‘#’ for block comment
E271 multiple spaces after keyword
E272 multiple spaces before keyword
E273 tab after keyword
E274 tab before keyword
E275 missing whitespace after keyword
E3 Blank line
E301 expected 1 blank line, found 0
E302 expected 2 blank lines, found 0
E303 too many blank lines (3)
E304 blank lines found after function decorator
E305 expected 2 blank lines after end of function or class
E4 Import
E401 multiple imports on one line
E402 module level import not at top of file
E5 Line length
E501 (^) line too long (82 > 79 characters)
E502 the backslash is redundant between brackets
E7 Statement
E701 multiple statements on one line (colon)
E702 multiple statements on one line (semicolon)
E703 statement ends with a semicolon
E704 (*) multiple statements on one line (def)
E711 (^) comparison to None should be ‘if cond is None:’
E712 (^) comparison to True should be ‘if cond is True:’ or ‘if cond:’
E713 test for membership should be ‘not in’
E714 test for object identity should be ‘is not’
E721 (^) do not compare types, use ‘isinstance()’
E731 do not assign a lambda expression, use a def
E741 do not use variables named ‘l’, ‘O’, or ‘I’
E742 do not define classes named ‘l’, ‘O’, or ‘I’
E743 do not define functions named ‘l’, ‘O’, or ‘I’
E9 Runtime
E901 SyntaxError or IndentationError
E902 IOError
W1 Indentation warning
W191 indentation contains tabs
W2 Whitespace warning
W291 trailing whitespace
W292 no newline at end of file
W293 blank line contains whitespace
W3 Blank line warning
W391 blank line at end of file
W5 Line break warning
W503 (*) line break occurred before a binary operator
W6 Deprecation warning
W601 .has_key() is deprecated, use ‘in’
W602 deprecated form of raising exception
W603 ‘<>’ is deprecated, use ‘!=’
W604 backticks are deprecated, use ‘repr()’

PyCharm选择性忽略PEP8代码风格警告信息相关推荐

  1. Python:PyCharm选择性忽略PEP8警告

    Python:PyCharm选择性忽略PEP8警告 PyCharm 是个很强大的 python IDE,PEP 8 的告警提示也很好用,但是函数名不能包含大写字母等少数几个规范真心觉得不好,如何取消呢 ...

  2. 一文搞懂 PEP8 代码风格

    0.为什么需要PEP8? PEP8存在是为了提高代码的可读性. 1.命名约定 命名样式 类型 命名约定 例子 Class 每个单词都大写字母开头:不要用下划线 Model, MyClass Const ...

  3. PyCharm:选择性忽略 PEP8 警告

    PyCharm 是个很强大的 python IDE,PEP 8 的告警提示也很好用,但是函数名不能包含大写字母等少数几个规范真心觉得不好,作为一名处女座强迫症患者,代码下面的波浪线这种东西是绝对不允许 ...

  4. PyCharm使用教程:选择性忽略 PEP8 警告

    PyCharm 是个很强大的 python IDE,PEP 8 的告警提示也很好用,但是函数名不能包含大写字母等少数几个规范真心觉得不好,作为一名处女座强迫症患者,代码下面的波浪线这种东西是绝对不允许 ...

  5. 【PyCharm警告】选择性忽略 PEP8 警告

    提示: Class names should use CamelCase convention Inspection info:This inspection checks the PEP8namin ...

  6. Python PEP8 代码规范常见问题及解决方法

    之前一直用 Python IDLE 写代码,最近换成 PyCharm 写代码总是会出现波浪号,这才了解到 Python 的 PEP8 代码规范,所以将常见的 PEP8 代码规范问题和解决方法记录一下, ...

  7. 最全Pycharm教程(2)——代码风格

    如果觉得这篇文章对您有所启发,欢迎关注我的公众号,我会尽可能积极和大家交流,谢谢. 1.主题 这部分教程主要介绍如何创建一个Python工程并使其具有Pycharm的代码风格.你将会看到Pycharm ...

  8. python代码模板_代码风格与文件模板

    1.文件模板 敢问童鞋们,是否有见过其他人的pycharm代码,上方总有一行"注释"一样的代码? 既能保留当时写代码的时间,也能指定文件字符编码,竟然还可以有一个署名!作者权呀! ...

  9. PEP8 - Python 代码风格指南中英对照

    PEP8 - Python 代码风格指南中英对照 Introduction A Foolish Consistency is the Hobgoblin of Little Minds Code la ...

最新文章

  1. requirejs模块化html,requirejs模块化-入门
  2. 【杂谈】野生在左 科班在右——数据结构学习誓师贴
  3. 学Python怎么样 发展前景如何
  4. Microsoft AI - Custom Vision in C#
  5. MyEclipse中Maven Web项目部署路径设置
  6. Vue 子组件调用父组件的方法
  7. JAVA中toString方法的作用
  8. Ubuntu 中如何使用 PPA 安装应用程序
  9. 深入解读Linux进程调度系列(8)——调度与cgroup
  10. wcf部署到IIS上,安装iis和wcf组件方法,并提供wcf文件
  11. 原生js发送ajax请求
  12. clustalw序列比对_序列比对之Clustalx与Clustalw使用指南
  13. 我的世界Java版中怎么改名_我的世界怎么改名字 付/免费改名字教程
  14. 无悔入华夏怎么一直显示服务器,无悔入华夏怎么统一_无悔入华夏统一方式技巧攻略_玩游戏网...
  15. python统计图作息规律统计分析_借鉴柳比契夫时间统计法,用Python做了个时间管理工具TMTask...
  16. esc键 qt 退出菜单_【Qt】QDialog之屏蔽Esc键【转】
  17. html5百度地图展示运动轨迹,百度地图根据经纬度获取运动轨迹
  18. 名片管理系统 #python项目 #演练 #增删改查CRUD #全程教程
  19. leetcode和牛客网刷题
  20. openjudge 1.5.7 奥运奖牌计数

热门文章

  1. 关闭2345,搜狐等软件的弹窗
  2. JVM|记一次生产环境 CPU 占用飙高问题解决
  3. 电脑页面怎么没有计算机,如何找回电脑里消失的IE浏览器图标?
  4. 机器学习阶段性总结[机器学习]
  5. 截断二进制指数退避算法c++实现
  6. 告诉你60个经典的电脑使用技巧
  7. MySQL面试:索引为啥使用B+树而不是B树
  8. 青岛再添新动脉|唐河路—安顺路预计年底通车
  9. Linux环境下安装tomcat并配置开机自启
  10. dbpedia知识图谱java_一种基于DBpedia的水务领域概念知识图谱构建方法与流程