有容乃大_python3

有容乃大

http://www.nowcoder.com/questionTerminal/4712159bbc15417086d40d6c6ff94fee

感觉python3没法写啊,没这么多类型。。。

import sys
sgs = sys.getsizeof
ll = ['short', 'int', 'long', 'long long']
for x in ll:
    print('The size of {} is {} bytes.'.format(x, sgs(int())))

坑爹啊,python3.5的编译器不保证有序。。。

table = {'short':2, 'int':4, 'long':8, 'long long':8}
for typ,size in table.items():
    print('The size of {} is {} bytes.'.format(typ, size))

#print('The size of short is 2 bytes.')
#print('The size of int is 4 bytes.')
#print('The size of long is 8 bytes.')
#print('The size of long long is 8 bytes.')
全部评论
table = {'short':2,'int':4,'long':8,'long long':8} for k,v in table.items(): print(f'The size of {k} is {v} bytes.')
2 回复 分享
发布于 2021-06-10 17:28

相关推荐

况世奇才:我七月投的Java,面试官说搞大数据的,挂个Java的吸引进来投简历的,已经offer评估了看看能不能泡出来吧
点赞 评论 收藏
分享
评论
12
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务