标签:每日 漏洞 cep ted def not top pre ima
class A(object): def go(self): print("go A go!") def stop(self): print("stop A stop!") def pause(self): raise Exception("Not Implemented") class B(A): def go(self): super().go() print( "go B go!") class C(A): def go(self): super().go() print("go C go!") def stop(self): super().stop() print("stop C stop!") class D(B,C): def go(self): super().go() print("go D go!") def stop(self): super().stop() print("stop D stop!") def pause(self): print("wait D wait!") class E(B,C): pass a = A() b = B() c = C() d = D() e = E() # 说明下列代码的输出结果 print("--------------") a.go() #"go A go!" b.go() #B继承A:"go A go!" "go B go!" c.go() #C继承A:"go A go!" "go C go!" d.go() #D继承B,C:从后往前C继承A:"go A go!" "go C go!" B继承A: "go B go!" "go D go!"只继承一次 e.go() #E继承B,C:C继承A:"go A go!" "go C go!" B继承A:"go B go!" print("-------------") a.stop() #"stop A stop!" print(‘123‘) b.stop() #B继承A:B本身没有stop方法:"stop A stop!" print("123") c.stop() #C继承A:"stop A stop!" "stop C stop!" d.stop() #D继承B,C:C继承A:"stop A stop!" "stop C stop!" "stop D stop!" e.stop() #E继承B,C:C继承A:"stop A stop!" "stop C stop!" print("$$$$$$$$$$$$$$") a.pause() #直接抛出异常了,程序结束,后面的程序都不会执行了 # 关键字raise是用来抛出异常的,一旦抛出异常后,后续的代码将无法运行。这实际上的将不合法的输出直接拒之门外,避免黑客通过这种试探找出我们程序的运行机制,从而找出漏洞,获得非法权限。 print("!!!!!!!!!!!!") b.pause() c.pause() d.pause() e.pause()
运行结果:
标签:每日 漏洞 cep ted def not top pre ima
原文地址:https://www.cnblogs.com/shuimohei/p/10367611.html