“'set' object is not subscriptable”意味着你试图通过索引(例如,使用my_set[0])来访问集合中的元素,但集合(set)是一种无序的、不包含重复元素的数据结构,它不支持通过索引来访问元素。 二、导致错误的常见情况 尝试通过索引访问集合元素: python my_set = {1, 2, 3} print(my_set[0]) # TypeError...
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 = ("你大爷"...
“TypeError: object is not subscriptable” 意味着我们正在使用方括号来访问特定对象中的键或访问特定索引,但是,该对象不支持此功能。 集合对象是无序的,因此不可订阅。 为了解决这个错误,我们必须使用列表或字典而不是集合,或者删除试图访问集合中的索引或键的方括号。 我们应该只使用方括号来访问可订阅对象。 Pyth...
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--...
Using a set in a context where a subscriptable object is expected How to solve Typeerror: ‘set’ object is not subscriptable 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 ...
Alternatively, you can also convert the set to a tuple to avoid the TypeError: 'set' object is not subscriptable: my_tuple = tuple(my_set) Let’s end this article with a bit of humor, shall we? Programmer Humor There are only 10 kinds of people in this world: those who know binar...
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...
main_activities is of type set, but index access was used, resulting in TypeError. Use the sorted() method to convert it to a list type, and then access it through subscripts. fix 'set' object is not subscriptable. f8c7972 Contributor Author Forgo7ten commented Mar 16, 2024 @erev0...
Python报错TypeError: 'set' object is not subscriptable 2020-09-16 15:35 −... 粥店接济 0 4012 TypeError: Object(…) is not a function 2019-12-18 14:35 −vue中遇到的这个错误 1. 先检查变量名或者函数名是否有重复定义 报这错之后看了好久,也没有发现starkflow上说的,重复定义了变量或者函...