0
我有一些非常奇怪的行爲,使用jupyter notebook
。爲什麼jupyter筆記本投擲IndentationError?
這是一個基本的Python功能:
def configure_wg_drem(data_file_pattern): return data_file_pattern
configure_wg_drem('Adult/Adult_*.txt')
這給了我:
'Adult/Adult_*.txt'
但與普通的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筆記本給出的自動縮進,當您使用冒號並按下Enter鍵,單個選項卡以及四個空格而不是選項卡時。所有結果都一樣。
我也試過重新啓動jupyter notebook
並得到相同的行爲。
你確定中間沒有不可打印的字符嗎?創建一個新的單元格,寫出'def foo(bar):\ nreturn bar',嘗試並將其變形,直到它看起來像您的原始示例。 – user2722968