摘要: Tuples:T = (1, 2, 3, 4)len(T)T + (5, 6)T.index(4)T.count(4)#Tuples are immutableSets:T = (1, 2, 3, 4)len(T)T + (5, 6)T.index(4)T.count(4)#Tuples are immutableFractions:from fractions import Fractionf = Fraction(2, 3)f+1f + Fraction(1, 2)Types:L = [2, 3, 4]type(L) #<class 'list'> for 3. 阅读全文
posted @ 2011-10-28 17:27 Aeol Kong 阅读(200) 评论(0) 推荐(0)
摘要: Mapping a dictionary:D = {'food': 'Spam', 'quantity':4} #build with {}D = dict(food='Spam', quantity=4) #build with dict()D={}D['key'] = 'value' #add key,value to a dict.#Sorting Keys:for key in sorted(D): print(key, '=>', D[key])#Missing Ke 阅读全文
posted @ 2011-10-28 17:17 Aeol Kong 阅读(207) 评论(0) 推荐(0)