如果我然後嘗試刪除重複我得到一個TypeError ...爲什麼?刪除重複的字符串列表類型錯誤python
tempList =列表(集(tempList))
錯誤:類型錯誤:文件行29: 'STR' 對象不是可調用#
這纔是真正的代碼:
# Lists all UI elements
allUI=pm.lsUI()[24:28]
#Main Window Name
win='searchElementsUI'
#Lists for UI Hierachy
allSplitUI=[]
maxLenUI=[]
parentDict={}
#Splits UI Elements
for ui in allUI:
allSplitUI.append(ui.split('|'))
#Max length of UISplit
for ui in allSplitUI:
maxLenUI.append(len(ui))
maxLenUI=max(maxLenUI)
#Adds main Parents to list
tempList=[]
for i in range(maxLenUI):
tempList=[]
for ui in allSplitUI:
try:
tempList.append(ui[i])
except:pass
tempList=list(set(tempList))
parentDict['list%s'%i]=tempList
這裏從maya完整回溯:
# Lists all UI elements
allUI=pm.lsUI()
#Main Window Name
win='searchElementsUI'
#Lists for UI Hierachy
allSplitUI=[]
maxLenUI=[]
parentDict={}
#Splits UI Elements
for ui in allUI:
allSplitUI.append(ui.split('|'))
#Max length of UISplit
for ui in allSplitUI:
maxLenUI.append(len(ui))
maxLenUI=max(maxLenUI)
#Adds main Parents to list
tempList=[]
for i in range(maxLenUI):
tempList=[]
for ui in allSplitUI:
try:
tempList.append(ui[i])
except:pass
tempList=list(set(tempList))
parentDict['list%s'%i]=tempList
# Error: 'str' object is not callable
# Traceback (most recent call last):
# File "<maya console>", line 29, in <module>
# TypeError: 'str' object is not callable #
這不是你真正的代碼。你不會從那個代碼中得到這個錯誤。 – Marcin
我添加了真實的代碼。也許你可以幫忙 – arvidurs
添加整個真實的堆棧跟蹤。此外,這仍然不是你真正的代碼,因爲第29行不會有這個錯誤。 – Marcin