pep8规范-常见问题及处理

来源:互联网 发布:云计算的上市公司 编辑:程序博客网 时间:2024/06/08 07:49

错误记录:E501 line too long

处理:这个不可避免的,不要管就行。


错误记录:W292 no newline at end of file

处理:打个回车有新的一空行即可(新行不要有空格)。


错误记录:E302 expected 2 blank lines, found 1

处理:上面只有一行空白,但是需要两个空白行


错误记录:E231 missing whitespace after ‘,’

错误记录:E231 missing whitespace after ‘;’

翻译:“,”“:”后要有空格

举例:
        错误 print(“%s %s %s %s %s %s” % (A,B,D,E,K,L))

        正确 print(“%s %s %s %s %s %s” % (A, B, D, E, K, L))


错误记录:E225 missing whitespace around operator

翻译:符号(=、,、等)周围缺少空格

举例:

        错误 f=open(“D:\\test.txt”, “ab”)

        正确 f = open(“D:\\test.txt”,  “ab”)



原创粉丝点击