• day5 大纲


    01 昨日内容回顾
    list:
    增: append insert(index,object) extend() 迭代着追加
    删:
    pop(默认删除最后一个)按照索引去删除 有返回值
    remove 按照元素去删除
    clear 清空列表
    del l1 删除列表
    del l1[index] 按照索引删除
    del l1[0:3] 按照切片删除
    del l1[0:3:2] 按照切片删除

    l1[2] = 'alex'
    l1[1:3] = 'abcd' 迭代着添加
    l1[1:4:2] = [1, 33]
    查:
    索引,切片,切片(步长)
    for 循环

    index:通过元素查询索引
    count:查找某个元素在列表中的个数。
    sort:排序,默认从小到大排序
    sort(reverse=True) 从大到小
    l1.reverse()
    len() 统计列表的元素的总个数。
    l1 = [1, 2, ['alex', 'barry'], 33]
    l1[1] = 200
    l1[2][0] = l1[2][0].upper()


    元组:
    (1, 'alex', True)
    查:索引,切片, 切片(步长) for循环
    index,count,len()
    (1, 'alex', True,[1,2,3])


    range() : 当做:可控范围的数字列表
    与for循环结合。


    02 作业讲解
    03 字典
    why:
    1,列表如果存储大量的数据,查询速度相对慢一些。
    2,列表存储的数据一般没有什么关联性。
    [小潘, 175, 男,......]
    针对以上因素,python提供了一个基础数据类型:dict字典。
    数据类型的分类:
    容器型数据类型:list,tuple,dict set。
    非容器型数据类型:str bool int。

    可变(不可哈希)的数据类型:list,dict,set。
    不可变(可哈希)的数据类型:str,bool, int,tuple
    (1, 2, 'alex', [1,2,3,])
    b1 = True
    b1 = False
    l1 = [1, 2, 3]
    l1.append(666)


    what:字典:
    {'name': 'alex'} 以键值对形式存储的数据类型。
    1,字典的键必须是不可变(可哈希hash)的数据类型,唯一的不重复。
    字典的值可以是任意数据类型(对象)。
    2,字典的查询速度非常快。
    3,字典在3.5包括3.5之前是无序的,但是3.6优化机制,字典会按照创建字典之初的顺序排列。
    4,字典可以存储大量的关联性数据。
    {'name': 'alex','python3期':['小潘','春哥', '二师兄'],
     '太白':{
                'name':'太白金星',
                'id': 1306546743423,
                'phone': 1358225xxxx,
                'sex': ''
    
               }
    
    }
    作者:Mark.Yang

    -------------------------------------------

    个性签名:就算要出卖灵魂,也要找个付的起价钱的人

    如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

  • 相关阅读:
    Open source cryptocurrency exchange
    Salted Password Hashing
    95. Unique Binary Search Trees II
    714. Best Time to Buy and Sell Stock with Transaction Fee
    680. Valid Palindrome II
    Java compiler level does not match the version of the installed Java project facet.
    eclipse自动编译
    Exception in thread "main" java.lang.StackOverflowError(栈溢出)
    博客背景美化——动态雪花飘落
    java九九乘法表
  • 原文地址:https://www.cnblogs.com/yang950718/p/10201688.html
Copyright © 2020-2023  润新知