美文网首页
Python 基础

Python 基础

作者: Jayson_Jiang | 来源:发表于2018-01-03 00:07 被阅读0次

逻辑表达式: bool
not a : 非
a and b : a &b
a or b : a || b
a is b : a 和 b 是同一个对象
a is not b : a 和 b 不是同一个对象

列表 :' [] '

  1. cmp(list1,list2) 比较俩个列表的元素
  2. len(list) 列表元素个数
  3. max(list) 返回列表元素最大值
  4. min(list) 返回列表元素最小值
  5. list(seq) 将元组转化为列表

方法:

  1. list.append(obj) 再列表末尾添加一个元素
  2. list.count(obj) 统计某个元素在列表中出现的次数
  3. list.extend(obj) 在列表的末尾追加另一个序列多个值
  4. list.index(obj) 检索列表中第一个匹配项位置
  5. list.insert(index, obj) 将一个元素插入列表的某个位置
  6. list.pop(index) 移除列表中的一个元素
  7. list.remove(obj) 移除列表中第一个匹配项
  8. list.reverse() 反向列表元素
  9. list.sort([func]) 对原列表进行排序

元组 :'()'

字典 :'{key:value}'

相关文章

网友评论

      本文标题:Python 基础

      本文链接:https://www.haomeiwen.com/subject/qlecnxtx.html