zoukankan      html  css  js  c++  java
  • python list

    (1)properties:implemented by array
    (2)common methods
    lst=['d', 'd', 'g', 'n', 'o', 'y', 'y']
    append(element)
    sort()
    reverse()
    count() #lst.count('d') >>>2
    index() #lst.index('d')  return the index-order of 'd' founded for the first time
    expand(seq) 
    pop() #lst.pop([INDEX]) remove the INDEX element(default last), and return the element
    insert() #lst.insert(INDEX, OBJECT)
    (3)list slicing
    # lst
    # Note: left close and right open:[2,6)
    lst1 = lst[2:6:3] 
    # get the last two elements
    lst1 = lst[-2:]
    (4)create list
    list(range(10))
    list(range(3,10))
    list(range(2,10,2))
    (5)create list by expr
    lst = [x*x for x in range(10)]
    (6)insert element
    mode 1:list.insert(Index, Object)
    mode 2:lst[0:0] = ['a','b','c'] ##insert a new element at the list top
    (7)update element
    lst[0:2] = ['a','b']

  • 相关阅读:
    H5图片上传、压缩
    数据库基本操作
    数组遍历
    CURL
    获取IP
    Memcached的实战笔记
    修bug总结 (基于java语言)
    java开发工作的总结
    多线程测试类
    可清除的单例对象获取类
  • 原文地址:https://www.cnblogs.com/lifeinsmile/p/5405966.html
Copyright © 2011-2022 走看看