• python面试终极准备


    简述Python的深浅拷贝?
    将列表内的元素,根据位数合并成字典
    	lst = [1,2,4,8,16,32,64,128,256,512,1024,32769,65536,4294967296]  
    	  
    	# 输出  
    	{  
    	    1:[1,2,3,8],  
    	    2:[16,32,64],  
    	    3:[128,256,512],  
    	    4:[1024,],  
    	    5:[32769,65536],  
    	    6:[4294967296]  
    	}
    
    list = [1,2,4,8,16,32,64,128,256,512,1024,32769,65536,4294967296]
    dict={}
    for i in list:
        dict.setdefault(len(str(i)),[]).append(i)
    print(dict)
    
    ###源码解析
        def setdefault(self, *args, **kwargs): # real signature unknown
            """
            Insert key with a value of default if key is not in the dictionary.
            
            Return the value for key if key is in the dictionary, else default.
            """
            pass
    ###
      
    一行999
    print('
    '.join([' '.join(['%s*%s=%-2s' % (y, x, x*y) for y in range(1, x+1)]) for x in range(1, 10)]))
    #自叹不如
    自己最开始研究的
    f'{f'{i}*{j}={i*j}' for j in range(1,i+1)}' for i in range(1,10)

      

  • 相关阅读:
    epplus
    http://www.cmake.org/
    patheditor2
    emgu cv
    OpenCV
    Tesseract
    Blendar基金会
    安装服务windows,installutil
    R 软件
    历史为什么选择C语言?事实证明:暮年的C语言,依旧宝刀未老!
  • 原文地址:https://www.cnblogs.com/Lucifer77/p/10699646.html
Copyright © 2020-2023  润新知