''' 时间: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