[英]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.