码迷,mamicode.com
首页 > 编程语言 > 详细

week02_python内置数据结构__03

时间:2018-08-13 17:03:46      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:不可   不可变   initial   items   zed   item   元素   表示   init   

元组tuple

一个有序的元素组成的集合
使用小括号( ) 表示

元组是不可变对象

元组的定义 初始化

  • > 定义

    tuple() -> empty tuple
    tuple(iterable) -> tuple initialized from iterable‘s items

    t = tuple() #工厂方法
    t = ()
    t = tuple(range(1,7,2)) # iteratable
    t = (1,) # 一个元素元组的定义
    t = (1,)* 5 #(1, 1, 1, 1, 1)

week02_python内置数据结构__03

标签:不可   不可变   initial   items   zed   item   元素   表示   init   

原文地址:http://blog.51cto.com/limingyu/2159109

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!