为什么jupyter笔记本会抛出一个缩进错误?

2024-06-02 12:23:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用jupyter notebook有一些非常奇怪的行为。在

下面是一个基本的python函数:

def configure_wg_drem(data_file_pattern): return data_file_pattern

configure_wg_drem('Adult/Adult_*.txt')

这给了我:

^{pr2}$

但与普通python格式相同的函数:

def configure_wg_drem(data_file_pattern): 
    return data_file_pattern

configure_wg_drem('Adult/Adult_*.txt')

引发错误:

  File "<ipython-input-97-c97da191fc79>", line 29
    return data_file_pattern
         ^
IndentationError: expected an indented block

有人对此有什么解释吗?在

我尝试过使用jupyter notebook提供的自动缩进,当您使用冒号并按enter键时,一个制表符以及四个空格而不是制表符。结果都一样。在

我还尝试重新启动jupyter notebook并获得相同的行为。在


Tags: 函数txtdatareturnconfiguredefjupyter制表符