LIst也可以通過,為什么要有set的存在?
months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul','Aug','Sep','Oct','Nov','Dec') x1 = 'Feb' x2 = 'Sun' if x1 in months: ? ?print 'x1: ok' else: ? ?print 'x1: error' if x2 in months: ? ?print 'x2: ok' else: ? ?print 'x2: error' LIst也可以通過,為什么要有set的存在?
2018-03-08
2017-12-12
因為set里面放的東西是鍵名屬性,檢索的快,list里面放的鍵值屬性 檢索的慢(原諒我用數組來解釋python的set和list)