tuple函数

 1 #tuple函数的功能和list函数基本上一样,都是以一个序列作为参数,并把它转换为元组。如果参数是元组,参数就会被原样返回。
 2 #示例如下:
 3 >>> tuple('hello','world')      #参数是元组
 4 Traceback (most recent call last):
 5   File "<pyshell#52>", line 1, in <module>
 6     tuple('hello','world')      #参数是元组
 7 TypeError: tuple() takes at most 1 argument (2 given)
 8 >>> tuple(('hello','world'))    #参数是元组
 9 ('hello', 'world')
10 #由上面的操作看到,tuple函数传入元组参数后,得到的返回值就是传入的参数。

 

posted @ 2017-10-19 11:52  爱你无目的  阅读(1341)  评论(0编辑  收藏  举报