擅长:python、mysql、java
<p>如错误消息所示,不能为<code>map</code>对象下标(方括号)。在python中,映射是一种<em>iterable</em>类型,这意味着从映射中获取数据的唯一方法是一次遍历一个元素。如果要为其下标,则需要将其存储为列表。你知道吗</p>
<pre><code>config.input = list(map(int, pLst))
</code></pre>
<p>正如这个简单的示例所示,不能为map对象下标。你知道吗</p>
<pre><code>>>> x = [0, 1, 23, 4, 5, 6, 6]
>>> y = map(str, x)
>>> y
<map object at 0x02A69DB0>
>>> y[1]
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
y[1]
TypeError: 'map' object is not subscriptable
</code></pre>
<p>要从map对象中获取数据:</p>
<pre><code>>>> for i in y:
print(i)
0
1
23
4
5
6
6
</code></pre>