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函数传入元组参数后,得到的返回值就是传入的参数。

 

相关文章:

  • 2021-05-27
  • 2022-01-15
  • 2022-12-23
  • 2021-08-04
  • 2021-11-10
  • 2022-12-23
  • 2021-10-13
  • 2021-11-06
猜你喜欢
  • 2021-09-11
  • 2021-07-26
  • 2021-08-31
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案