最贊回答 / lxhxh99
set的元素不能重復,為了保證不重復,set的元素必須是不可變的,而list的可變的,所以set里不能有list。反證法解釋一下,假如 set里可以有list,則L1 = [1,2,3]L2 = [1,2]s = set([L1,L2])? ?s里有[1,2,3]與[1,2] 兩個list,由于list的可變的,如果執行L1.pop()L1變為[1,2]? 和 L2 的值一樣了?s里就有重復的元素了,與set的定義相悖,所以set里不可以有list。
2018-08-08
已采納回答 / 南罧
a=Trueprint a and 'a=T' or 'a=F'and : x and y,當x為false時,返回false;否則,返回y。所以 True and 'a=T' 返回 'a=T'or: x or y,當x為true時,返回x;否則,返回y。所以 'a=T' or 'a=F' 返回 'a=T'
2018-08-08
已采納回答 / Jiong_jia
當然錯誤啊。你while后面怎么沒有了?這樣會報錯的。正確應該是:sum?=?0x?=?1????while?x<100:????????sum=sum+x????x=x+1print?sum/2
2018-08-08
最新回答 / liujlb
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }def generate_tr(name, score):? ? if score >= 60:? ? ? ? return '<tr><td>%s</td><td>%s</td></tr>' %(name, score)? ? else:? ? ? ? return '<tr><td>%s</td><t...
2018-08-08
最贊回答 / qq_那年花開的時候_0
L = ['Adam', 'Lisa', 'Bart', 'Paul']for index, name in enumerate(L):? ? print index+1, '-', name
2018-08-07