zoukankan      html  css  js  c++  java
  • Pyhton数据类型总结

    数据类型比较
    按存储模型分类
    • 标量类型:数值,字符串
    • 容器类型:列表,元组,字典
    按更新模型分类:
    • 可变类型:列表,字典
    • 不可变类型:数字,字符串,元组
    按访问模型分类
    • 直接访问:数字
    • 顺序访问:字符串。列表,元组
    • 映射访问:字典

    容器的意思是还可以有其他对象,数字字符串是标量类型,不能包含其它的元素了

    >>> pystr = 'Python'
    >>> pystr[0]
    'P'
    >>> pystr[0] = 'p'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'str' object does not support item assignment
    >>> alist 
    [1, 'tom', 2, 'alice', 3, [20, 30]]
    >>> blist = alist
    >>> alist[0] = 100
    >>> alist
    [100, 'tom', 2, 'alice', 3, [20, 30]]
    >>> blist
    [100, 'tom', 2, 'alice', 3, [20, 30]]
    >>> clist = alist[:]
    >>> clist
    [100, 'tom', 2, 'alice', 3, [20, 30]]
    >>> clist.append('lee')
    >>> clist
    [100, 'tom', 2, 'alice', 3, [20, 30], 'lee']
    >>> alist
    [100, 'tom', 2, 'alice', 3, [20, 30]]

    字符串,元组,列表:可以切片

  • 相关阅读:
    MySQL视图
    MySQL触发器
    SQL语法详解
    MySQL函数和操作符
    MySQL常用查询
    MySQL数据类型
    MySQL操作详解
    MySQL学习-SQL约束
    MySQL 其它基本操作
    MySQL创建数据库并插入数据
  • 原文地址:https://www.cnblogs.com/weiwenbo/p/6552663.html
Copyright © 2011-2022 走看看