Python错误集锦:三引号注释提示错误:IndentationError: expected an indented block

原文链接:http://www.juzicode.com/archives/2840

错误提示:

定义函数时,使用三引号注释提示错误:IndentationError: expected an indented block

#juzicode.com/vx:桔子code
def fuc():
'''
定义一个函数
'''
    print('桔子code')
    print('juzicode.com')    
    return None

#调用func函数
fuc()

 

可能原因:

1、三引号注释存在缩进错误。

 

解决方法:

1、 三引号注释应该当成占位符和def对齐书写,详细解释可以参考:好冷的Python–三引号注释,你的要求为什么这么多!

#juzicode.com/vx:桔子code
def fuc():
    '''
    定义一个函数
    '''
    print('桔子code')
    print('juzicode.com')    
    return None

#调用func函数
fuc()

 
posted @ 2020-12-21 21:04  桔子code  阅读(347)  评论(0编辑  收藏  举报