python3中报错:TypeError: 'range' object doesn't support item deletion
2016-10-31 22:24
656 查看
通过range构造数组
trainingSet = range(50);
在执行以下操作时del(trainingSet[randIndex])
报错:TypeError: 'range' object doesn't support item deletion
原因是python3中range不返回数组对象,而是返回range对象
解决办法将<pre name="code" class="python">trainingSet = range(50);替换为trainingSet = list(range(50));
相关文章推荐
- python3中报错:TypeError: 'range' object doesn't support item deletion
- python 报错TypeError: 'range' object does not support item assignment,解决方法
- python 3.6.2 TypeError: 'range' object doesn't support item deletion
- 'range' object doesn't support item deletion
- 'range' object doesn't support item deletion
- python 编译错误TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
- python:TypeError: 'coo_matrix' object has no attribute '__getitem__'
- python :TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
- python提示错误TypeError: 'dict_keys' object does not support indexing
- TypeError: 'str' object does not support item assignment 的解决方法
- python3.6 TypeError: 'dict_keys' object does not support indexing
- TypeError: 'ItemMeta' object does not support item assignment
- theano 中出现 TypeError: 'TensorVariable' object does not support item assignment
- TypeError: 'module' object is not callable 原因分析(python模块导入注意事项)
- Python Numpy ValueError: data type must provide an itemsize
- TypeError: 'tuple' object is not callable 分类: python学习 2014-03-18 10:51 696人阅读 评论(0) 收藏
- python——TypeError: 'str' does not support the buffer interface
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- python 点滴记录4:TypeError: range() integer end argument expected, got str.
- python Flask :TypeError: 'dict' object is not callable