第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

顯示TypeError: 'list' object is not callable,這是什么原因?

顯示TypeError: 'list' object is not callable,這是什么原因?

慕桂英546537 2022-04-21 15:15:15
class test:def list(self):list = []return listprint test().list()運(yùn)行結(jié)果:[]但如果這樣:class test:def __init__(self):self.list=[]def list(self):list = []return listprint test().list()就會報(bào)錯(cuò),像這樣:Traceback (most recent call last):File "C:\Users\pqj123\Desktop\test.py", line 7, in <module>print test().list()TypeError: 'list' object is not callable這是什么原因,求指教。
查看完整描述

2 回答

?
智慧大石

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊

error已經(jīng)告訴你了 list對象不能用函數(shù)形式調(diào)用,就是不能callable。
簡單來說就是list變量和list函數(shù)重名了。

查看完整回答
反對 回復(fù) 2022-04-24
?
斯蒂芬大帝

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

>>> list('asdf')
Traceback (most recent call last):
File "<pyshell#154>", line 1, in <module>
list('asdf')
TypeError: 'list' object is not callable
你可以先確認(rèn)一下list變量是否被使用:

>>> list #輸入list回車,檢查list的值
[1, 3, 2, 4, 6, 7, 12, 10] #發(fā)現(xiàn)list被占用
>>> del list #刪除變量
>>> list #確認(rèn)一下結(jié)果
<class 'list'> #變量被刪除
>>> list('adfadf') #再次調(diào)用list()函數(shù)
['a', 'd', 'f', 'a', 'd', 'f'] #可以正常使用了。



查看完整回答
反對 回復(fù) 2022-04-24
  • 2 回答
  • 0 關(guān)注
  • 583 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號