资讯详情

PyCharm 提示PEP 8: E302 expected 2 blank lines, found 1

使用pycharm编写python程序的时候,总会在def function()有以下问题:

PEP 8: E302 expected 2 blank lines, found 1

造成这个问题的原因:在声明函数的行上方必须有两行空行,否则就会发生这种情况。

eg:

# This is a sample Python script.  # Press Shift F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.   def print_hi(name):     # Use a breakpoint in the code line below to debug your script.     print(f'Hi, {name}')  # Press Ctrl F8 to toggle the breakpoint.   def print_string():     # 字符串声明:单引号和双引号等价     name1 = 'Hi Python3'     print(name1)     name2 = "Hi Python3"     print(name2)     # 字符串声明:三引号包含多行字符串     name3 = """Hi         Python3"""     print(name3)   # Press the green button in the gutter to run the script. if __name__ == '__main__':     print_hi('PyCharm')     # 整数相加     print(2   2)     # 浮点数相加     print(2.0   2.5)     # 整数加浮点数     print(2   2.5)     # 变量赋值     a = 10     print(a)     # 字符串声明函数     print_string() # See PyCharm help at https://www.jetbrains.com/help/pycharm/ 

标签: 2e302电容柜用

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台