Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 692 Bytes

48.md

File metadata and controls

26 lines (18 loc) · 692 Bytes
@author jackzhenguo
@desc 
@date 2019/3/4

48 查看变量所占字节数

getsizeof查看变量占用字节数 看到:字典比列表占用更多空间

In [1]: import sys

In [3]: a = [('a',1),('b',2)]                                                                                                             

In [5]: sys.getsizeof(a)                                                        
Out[5]: 88


In [6]: a = {'a':1,'b':2.0}                                                     
In [7]: sys.getsizeof(a)                                                        
Out[7]: 248
[上一个例子](47.md) [下一个例子](49.md)