python中expected an indented block
时间: 2023-09-20 11:14:43 浏览: 87
一个等待显示的代码
在Python中,当使用条件语句(如if、while、for、try-except)时,必须在语句后面加上一个冒号(:),并且在下一行起始位置进行缩进。缩进的代码块表示与条件语句相关的从属关系。如果在条件语句后面没有缩进的代码块,Python解释器会报错并提示"expected an indented block"。这个错误意味着解释器期望在条件语句后面有一个缩进的代码块,用来执行与条件相关的指令。因此,为了解决这个错误,你需要在条件语句后面添加一个缩进的代码块来执行相应的操作。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [python常见错误.txt](https://download.csdn.net/download/qq_43966957/87896394)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Python中expected an indented block](https://blog.csdn.net/u010281626/article/details/53885638)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文