我在看<父与子的编程之旅>的时候,有段代码是随机画100个矩形,矩形的大小,线条的粗细,颜色都是随机的,代码如下, import pygame,sys,random from pygame.color import THECOLORS pygame.init() screen = pygame.display.set_mode([640,480]) screen.fill([255,255,255]) for i in range(100): width = random.randint(0,…
之前看python文档的时候发现许多单继承类也用了super()来申明父类,那么这样做有何意义? 从python官网文档对于super的介绍来看,其作用为返回一个代理对象作为代表调用父类或亲类方法.(Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been…
在 python2 中zip可以将两个列表并入一个元组列表,如: a = [1,2,3,4] b = [5,6,7,8] c = zip(a,b) 结果:c [(1,5),(2,6),(3,7),(4,8)] 在python3中zip返回值有所改变: >>> a = [1,2,3,4]>>> b = [5,6,7,8]>>> c = zip(a,b)>>> c<zip object at 0x03496878> 可以看到返…
在python中,一切皆对象,应该怎么理解呢?? 先来看几个例子: [root@localhost ~]# python3 Python 3.6.3rc1 (default, Feb 26 2018, 22:34:25) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux Type "help", "copyright", "credits" or "license" for mo…