Python[六]:Tuples and Sequences

Tuples and Sequences >>> t=12345,54321,'hello' >>> t[0] 12345 >>> t (12345, 54321, 'hello') >>> u=t,(1,2,3,4,5) >>> u ((12345, 54321, 'hello'), (1, 2, 3, 4, 5)) >>> empty=() >>> singleton='hello', >>> len(empty) 0 >>> len(singleton) 1 >>> singleton ('hello',) >>> x,y,z=t >>> x 12345 >>> y 54321 >>> z 'hello' >>> x,y,z=t,t,t >>> x (12345, 54321, 'hello') >>> y (12345, 54321, 'hello') >>> t (12345, 54321, 'hello') >>> x,y=t Traceback (most recent call last): File "<pyshell#155>", line 1, in <module> x,y=t ValueError: too many values to unpack >>> 

你可能感兴趣的:(Python[六]:Tuples and Sequences)