Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common problems of Python PEP8 code specification

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "Python PEP8 code specification common problems", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Python PEP8 code specification common problems" this article.

PEP 8: no newline at end of file

Solution: a new line is needed at the end of the code, and the cursor can be moved to the last enter.

PEP 8: indentation is not a multiple of four

Solution: indent is not a multiple of 4, check indent

PEP 8: over-indented

Solution: excessive indentation, check indentation

PEP 8: missing whitespace after','

Solution: lose the space after the comma, just add the space, similar to the semicolon or colon.

PEP 8: multiple imports on one line

Solution: do not reference multiple libraries in an import sentence, for example: import socket, urllib.error had better be written as: import socket import urllib.error

PEP 8: blank line at end of line

Solution: if there are more spaces at the end of the code, you can delete them.

PEP 8: at least two spaces before inline comment

Solution: there should be at least two spaces between code and comments

PEP 8: block comment should start with'#'

Solution: comments start with # plus a space

PEP 8: inline comment should start with'#'

Solution: comments start with # plus a space

PEP 8: module level import not at top of file

Solution: import is not at the top of the file, there may be other code before it

PEP 8: expected 2 blank lines,found 0

Solution: two blank lines are required, and you can add two blank lines

PEP 8: function name should be lowercase

Solution: change the name of the function to lowercase

PEP 8: missing whitespace around operator

Solution: operator ('=','>','79 characters) E502the backslash is redundant between bracketsE7StatementE701multiple statements on one line (colon) E702multiple statements on one line (semicolon) E703statement ends with a semicolonE704 (*) 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:'E713test for membership should be 'not in'E714test for object identity should be' is not'E721 (^) do not compare types Use 'isinstance ()' E722do not use bare except, specify exception insteadE731do not assign a lambda expression, use a defE741do not use variables named'lager, 'oval, or' I'E742do not define classes named'lager, 'oval, or' I'E743do not define functions named'lame,'O' Or 'I'E9RuntimeE901SyntaxError or IndentationErrorE902IOErrorW1Indentation warningW191indentation contains tabsW2Whitespace warningW291trailing whitespaceW292no newline at end of fileW293blank line contains whitespaceW3Blank line warningW391blank line at end of fileW5Line break warningW503 (*) line break before binary operatorW504 (*) line break after binary operatorW505 (* ^) doc line too long (82 > 79 characters) W6Deprecation warningW601.has_key () is deprecated, use' in'W602deprecated form of raising exceptionW603'' is deprecated, use'! = 'W604backticks are deprecated Use 'repr ()' W605invalid escape sequence'x contains W606 frequently async 'and' await' are reserved keywords starting with Python 3.7 and above is all the content of the article "what are the frequently asked questions about Python PEP8 Code specifications?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report