如何实现tuple与list 的转换
1、tp = (11, 22, 33, 44)print(type(tp))tp_list = list(tp)print(type(tp_list))这里有个tuple,转换为list,我们用list()函数就可以转换了。

3、tp = (11, 22, 33, 44)tp_list = list()for i in tp: tp_list.append(i)print(tp_list)创建列表的形式也可以允许这样书写,结果是一样的。

5、但是我们不能用循环添加的方法来转换为tuple,因为tuple是不可改变的数据类型。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:45
阅读量:92
阅读量:92
阅读量:69
阅读量:63