zoukankan      html  css  js  c++  java
  • 010 python语法_函数 sys.getsizeof()

    '''
    时间:2018/10/30
    目的: 显示数据类型大小 
    '''
    # coding:utf-8
    import sys
    
    # 数据类型
    int = 100
    bool = True
    float = 1.1
    str =""
    list = []
    tuple =()
    dict = {}
    set = set([])
    
    
    # 显示大小
    print("%s size is %d" %(type(int), sys.getsizeof(int)))
    print("%s size is %d" %(type(bool), sys.getsizeof(bool)))
    print("%s size is %d" %(type(float), sys.getsizeof(float)))
    print("%s size is %d" %(type(str), sys.getsizeof(str)))
    print("%s size is %d" %(type(list), sys.getsizeof(list)))
    print("%s size is %d" %(type(tuple), sys.getsizeof(tuple)))
    print("%s size is %d" %(type(dict), sys.getsizeof(dict)))
    print("%s size is %d" %(type(set), sys.getsizeof(set)))
    <class 'int'>
    <class 'int'> size is 14
    <class 'bool'> size is 14
    <class 'float'> size is 16
    <class 'str'> size is 25
    <class 'list'> size is 36
    <class 'tuple'> size is 28
    <class 'dict'> size is 136
    <class 'set'> size is 116
  • 相关阅读:
    01-节点层次
    WebAPI02
    WebAPI01
    牛客剑指Offer7
    Python字典排序
    Python字典中的键映射多个值
    计算机硬件的主要技术指标
    计算机的基本组成
    计算机系统概论
    数据库概论
  • 原文地址:https://www.cnblogs.com/huafan/p/9879789.html
Copyright © 2011-2022 走看看