#!/usr/bin/python
# -*- coding:UTF-8 -*-

array = ("I","Love","U","and","you","love","me")
print array[0]
print array[1]
print array[2]
print array[0:-1]
print array[-4]


array1 = ("My","Name")
array2 = ("is","you")
arraysum = (array1,array2)
print "I want to say:",arraysum
arraytemp=arraysum[0][1]
print arraytemp

 

 遍历二元元组的一种方法:

#!/usr/bin/python
# -*- coding:UTF-8 -*-

 

array = (("I","Love"),("U","and"),("you","love"))
for i in xrange(len(array)):
    print "array[%d]"%i,""
    for j in xrange(len(array[i])):
                   print array[i][j]

另一种遍历方法利用map():

#!/usr/bin/python
# -*- coding:UTF-8 -*-

 

array = ("I","Love","U","and","you","love")
for x in map(None,array):
    for i in x:
        print i