#list to tuple lis=[1,2,3,4,5,6] x=tuple(lis) print(type(x),x) #tuple to list tup=(1,2,3,4,5,6) y=list(tup) print(type(y),y)
输出
(<type 'tuple'>, (1, 2, 3, 4, 5, 6)) (<type 'list'>, [1, 2, 3, 4, 5, 6])
#list to tuple lis=[1,2,3,4,5,6] x=tuple(lis) print(type(x),x) #tuple to list tup=(1,2,3,4,5,6) y=list(tup) print(type(y),y)
输出
(<type 'tuple'>, (1, 2, 3, 4, 5, 6)) (<type 'list'>, [1, 2, 3, 4, 5, 6])