摘要: 什么是异常? 异常即是一个事件,该事件会在程序执行过程中发生,影响了程序的正常执行。 一般情况下,在Python无法正常处理程序时就会发生一个异常。 异常是Python对象,表示一个错误。 当Python脚本发生异常时我们需要捕获处理它,否则程序会终止执行。 异常处理 捕捉异常可以使用try/exc 阅读全文
posted @ 2017-03-10 11:59 没有为什么 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 1 import socket 2 phone=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #买手机 3 phone.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) #就是它,在bind前加 阅读全文
posted @ 2017-03-10 11:49 没有为什么 阅读(455) 评论(0) 推荐(0) 编辑
摘要: 1 import socket 2 import struct 3 import json 4 import subprocess 5 phone=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #买手机 6 phone.setsockopt(soc 阅读全文
posted @ 2017-03-10 11:47 没有为什么 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1 import socketserver 2 class FtpServer(socketserver.BaseRequestHandler): 3 def handle(self): 4 print(self.request) #conn 5 print(self.client_address) 阅读全文
posted @ 2017-03-10 11:46 没有为什么 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 1 class Teacher: 2 def __init__(self,name,bitrh,course): 3 self.name=name 4 self.birth=bitrh 5 self.course=course 6 7 class Course: 8 def __init__(sel 阅读全文
posted @ 2017-03-10 11:43 没有为什么 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1 class Foo: 2 def __init__(self,name): 3 self.name=name 4 def __call__(self, *args, **kwargs): 5 print(' >') 6 f=Foo('egon') 7 f() 8 9 class Foo: 10 阅读全文
posted @ 2017-03-10 11:42 没有为什么 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 1 class A: 2 def test(self): 3 print('from A') 4 5 class B(A): 6 # def test(self): 7 # print('from B') 8 pass 9 class C(A): 10 # def test(self): 11 # 阅读全文
posted @ 2017-03-10 11:41 没有为什么 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 class Garen: 2 camp='Demacia' 3 def __init__(self,nickname,aggresivity,life_value): 4 self.nickname=nickname #g1.nicknam=nickname 5 self.aggrv=aggre 阅读全文
posted @ 2017-03-10 11:39 没有为什么 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 1 class Foo: 2 __x=1 3 def __init__(self,name,age,gender,money): 4 self.__name=name 5 self.__age=age 6 self.__gender=gender 7 self.__money=money 8 def 阅读全文
posted @ 2017-03-10 11:38 没有为什么 阅读(169) 评论(0) 推荐(0) 编辑
摘要: class People: def __init__(self,name,age,gender): self.name=name self.age=age self.gender=gender def test(self): print('from A.test') class Teacher(People): ... 阅读全文
posted @ 2017-03-10 11:37 没有为什么 阅读(120) 评论(0) 推荐(0) 编辑
摘要: lass Animal: def talk(self): pass class People(Animal): def talk(self): print('say hello') class Pig(Animal): def talk(self): print('say aoao') class Dog(Animal)... 阅读全文
posted @ 2017-03-10 11:35 没有为什么 阅读(304) 评论(0) 推荐(0) 编辑
摘要: class Foo: def __init__(self,name): self.name=name def func(self): print('--------------.func') print(hasattr(Foo,'func')) f=Foo('egon') print(hasattr(f,'x')) f.x=1 print(g... 阅读全文
posted @ 2017-03-10 11:33 没有为什么 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 面向对象的程序设计 1、面向对象的程序设计怎么来的 (面向对象的程序设计) 2、类和对象 从一组对象中提取相似的部分就是 类 类也是特征与技能的结合体(数据和函数的结合体) 实例化过程中,把实例当作第一个参数传给init本身 类的实例化 属性引用,包含数据属性和函数属性 对于一个实力来说,只有一种功 阅读全文
posted @ 2017-03-10 11:27 没有为什么 阅读(285) 评论(0) 推荐(0) 编辑