简体   繁体   English

为什么我在这里得到“ IndentationError:预期缩进的块”?

[英]Why am I getting “IndentationError: expected an indented block” here?

What the header says. 标头说什么。 I'm working in a Pythin 3 Jupyter Notebook. 我正在使用Pythin 3 Jupyter笔记本。

The code: 代码:

image[0].save(out_fname, save_all = True, quality=100, append_images = images[1:])

The error: 错误:

File "<ipython-input-22-976c7de2f57a>", line 8
    image[0].save(out_fname, save_all = True, quality=100, append_images = images[1:])
        ^
IndentationError: expected an indented block

EDIT: Here's the rest of the cell. 编辑:这是单元格的其余部分。

image = []
for i in range(min_range, max_range + 1):

image[0].save(out_fname, save_all = True, quality=100, append_images = images[1:])

Double edit: Attempting to tab the last line results in a "list index out of range" error. 双重编辑:尝试在最后一行中使用Tab键会导致“列表索引超出范围”错误。

Python requires indentation as part of its syntax. Python需要缩进作为其语法的一部分。 When declaring a for loop, an indentation tells Python that the code belongs to the loop. 声明for循环时,缩进告诉Python该代码属于该循环。

Changing 改变中

for i in range(min_range, max_range + 1):
image[0].save(out_fname, save_all = True, quality=100, append_images = images[1:])

to

for i in range(min_range, max_range + 1):
    image[0].save(out_fname, save_all = True, quality=100, append_images = images[1:])

should fix your issue. 应该解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我不断收到“IndentationError:期望一个缩进块” - I Keep Getting "IndentationError: expected an indented block" 为什么我会得到“预期一个缩进块”? - Why am I getting `expected an indented block`? 我在 np.random.seed(2) 中收到“IndentationError: expected an indented block”。 如何解决这个问题? - I am getting “IndentationError: expected an indented block” in np.random.seed(2). How to fix this? IndentationError: 期望一个缩进块,但我不知道为什么 - IndentationError: expected an indented block but i dont know why IndentationError - 需要一个缩进的块 - IndentationError - expected an indented block IndentationError:预期缩进块 - IndentationError: expected an indented block IndentationError 需要一个缩进块 - IndentationError expected an indented block Python:为什么我在elif(r &lt;= 9)上得到“预期的缩进块”: - Python: Why am I getting an “expected an indented block” on elif (r <= 9): 为什么我在 Python 文件上收到此错误“<stdin> ”,第 2 行 /n new_squares.append(squares[i]) /n ^ IndentationError: 期望缩进块?</stdin> - Why am I getting this error on Python File “<stdin>”, line 2 /n new_squares.append(squares[i]) /n ^ IndentationError: expected an indented block? 当我的代码正确缩进时,为什么会出现IndentationError? - Why am I getting an IndentationError when my code is properly indented?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM