在Python编程中,遇到“'set' object is not subscriptable”错误意味着你尝试对一个集合(set)对象进行了下标操作,但集合对象本身并不支持下标操作。下面是对这一错误的详细解释、常见情况以及解决方法的总结: 一、错误的含义 “'set' object is not subscriptable”意味着你试图通过索引(例如,使用my_set[0])来访问...
jobs = {"老师","程序员","打酱油的"}foriinrange(3):print("姓名:{0},年龄:{1},工作:{2}".format(names[i],ages[i],jobs[i]))#TypeError: 'set' object is not subscriptable#表示把不具有下标操作的集合对象用成了对象[i] 1 2 3 4 5 6 7 8 9 以下是正确案例: names1 = ("你大爷"...
当我对该方法进行函数调用时 create({'1','2'}) 我得到一个 TypeError: 'set' object is not subscriptable 在线错误 'AWS': list(map(lambda id: f"arn:aws:iam::{id}:root", ids[i:i + 200])) 。来自 java 背景,这是否与类型转换有关?该错误是否意味着我正在将一组数据结构传递给列表函数?这...
而以下代码是错误的: undefined_set =set# TypeError:'type'objectisnot subscriptable 复制代码 通过避免这些常见错误,你可以更有效地使用Python集合。
Here are some ways to fix the“TypeError: ‘set’ object is not subscriptable”error in Python. 1. Use a loop to iterate over the elements of the set Since sets in Python are unordered collections of unique elements, they do not support indexing or slicing. ...
class Htmloutputer(object): def __init__(self): self.datas=[] def collect_data(self,data):#收集数据 if data is None:#如果数据是空的就返回 return self.datas.append(data)#否则就往列表中添加data def output_json(self):#写出文件 fout=open('9udata.json','w') fout.write('{')#0--...
TypeError: 'set' object is not subscriptable 我到处找,找不到解决我案子的办法。我应该找什么? 看起来TryToFindCardInGame返回了一个集合,这与列表不同https://docs.python.org/3.5/library/stdtypes.html#set-types-set-frozenset 本站已为你智能检索到如下内容,以供参考: ...
python set元素访问 python中集合set主要利用其唯一性,及并集|、交集&等操作,但不可以直接通过下标进行访问,必须访问时可以将其转换成list再访问 x={1,2,5} y=list(x) a=y[1] a=x[1]#'set' object is not subscriptable 另:list、tuple、set初值的格式...
Rasa Core version: rasa_core==0.12.2 Python version: python 3.6.6 Operating system (windows, osx, ...): Linux-Ubuntu Issue: Getting error as TypeError: ‘SlotSet’ object is not subscriptable from custom action Please find the error log ER...
>>> s[0:2]Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: 'set' object is not subscriptable 但是,如果我们需要删除重复项,或者进行组合列表(与)之类的数学运算,那么我们可以,并且应该始终使用集合。我不得不提一下,在迭代时,集合的表现优于列表。所以,...