TypeError: 'range' object is not callable
时间: 2023-09-27 07:07:59 浏览: 236
这个错误发生在调用了range对象作为可调用函数时。在Python 3中,range返回的是一个迭代器,而不是一个可调用函数,因此不能像在Python 2中那样直接调用它。解决这个问题的一种方法是使用list()函数将range对象转换为列表,然后再调用它。你可以这样修改代码来解决这个问题:x = list(range(9)) [3。这样,你就可以将range对象转换为一个可调用的列表,在调用时不会出现TypeError错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [TypeError: 'range' object is not callable](https://blog.csdn.net/qq595662096/article/details/90440202)[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* [Pytorch报错记录](https://download.csdn.net/download/weixin_38572115/14852420)[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 ]
阅读全文