python元组与列表

1.list和tuple共同点和区别

同:元组tuple与列表List都是序列类型的容器对象,可以存放任何类型的数据

异:tuple 不可变序列(一般情况下) 

list 可变序列

2.定义一个变量,包含现在所学的数据类型


3.目前学到的序列有哪些?

字符串,字节,元组,列表

将除tuple之外的序列转换为tuple

 将除list之外的序列转换为list

 

 4.tuple中有哪些操作方法

cout  统计出现次数

index  返回第一个的索引

5.list中有哪些操作方法

append(self, object, /)
       Append object to the end of the list.

       #将对象追加到列表的末尾。
   
   clear(self, /)
       Remove all items from list.
       #从列表中删除所有项目。


   copy(self, /)
       Return a shallow copy of the list.
       #返回列表的浅层副本。


   count(self, value, /)
       Return number of occurrences of value.
      #返回值的出现次数。


   extend(self, iterable, /)
       Extend list by appending elements from the iterable.
       #通过从可迭代对象追加元素来扩展列表。


   index(self, value, start=0, stop=9223372036854775807, /)
       Return first index of value.
       #返回值的第一个索引。
       Raises ValueError if the value is not present.
      #如果值不存在,则提高值错误。


   insert(self, index, object, /)
       Insert object before index.
       #在索引之前插入对象。


   pop(self, index=-1, /)
       Remove and return item at index (default last).
       #删除并返回索引处的项目(默认在后面)。
       Raises IndexError if list is empty or index is out of range.
       #如果列表为空或索引超出范围,则引发索引错误。


   remove(self, value, /)
       Remove first occurrence of value.
       #删除第一个出现的值。
       Raises ValueError if the value is not present.
       #如果值不存在,则提高值错误。


   reverse(self, /)
       Reverse *IN PLACE*.
      #反向

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无敌暴龙兽z

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值