PyCharm 显示“PEP8:预期 2 个空行,发现 1 个"; [英] PyCharm shows "PEP8: expected 2 blank lines, found 1"

查看:44
本文介绍了PyCharm 显示“PEP8:预期 2 个空行,发现 1 个";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下代码:

def add_function(a, b):
    c = str(a) + b
    print "c is %s" % c

def add_int_function(c, d):
    e = c + d
    print "the vaule of e is %d" % e

if __name__ =="__main__":
    add_function(59906, 'kugrt5')
    add_int_function(1, 2)

它总是向我显示:expected 2 blank lines ,found 1" in aadd_int_function,但不在 add_function 中.

It always shows me: "expected 2 blank lines ,found 1" in aadd_int_function, but not in the add_function.

当我在def add_int_function(c, d)前加两个空格时:有一个错误显示 unindent 不匹配任何外部缩进级别add_function 的末尾:

When I add two spaces in front of the def add_int_function(c, d): there is a error shows unindent does not match any outer indentation level in the end of add_function:

推荐答案

只需在函数定义之间添加另一行:

Just add another line between your function definitions :

1 行:

2 行:

这篇关于PyCharm 显示“PEP8:预期 2 个空行,发现 1 个";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆