只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2018-04-11 13:49 夏晓旭 阅读(30) 评论(0) 推荐(0)
摘要: 单例:一个类只能生成唯一的一个实例 每个类只要被实例化了,他的私有属性 '_instance'就会被赋值,这样理解对吗 对 #方法1,实现__new__方法 #并在将一个类的实例绑定到类变量_instance上, #如果cls._instance为None说明该类还没有实例化过,则实例化该类,并返回 阅读全文
posted @ 2018-04-10 17:27 夏晓旭 阅读(2912) 评论(0) 推荐(1)
摘要: 生成指定长度的随机数字密码 生成指定长度的随机字母密码 生成指定长度的随机数字和字母的混合 #encoding=utf-8 import random import string class password_generator: password_time=0 def __init__(self, 阅读全文
posted @ 2018-04-10 13:25 夏晓旭 阅读(290) 评论(0) 推荐(0)
摘要: #coding=utf-8 class Person(object): def __init__(self,name,age): self.name=name self.age=age def get_age(self): return self.age def get_name(self): re 阅读全文
posted @ 2018-04-10 13:06 夏晓旭 阅读(980) 评论(0) 推荐(0)
摘要: 用类方法和静态方法实现:一个是追加写文件一行内容,一个是读指定行号的内容 #coding=utf-8 class handle_file(object): def __init__(self,file_path): self.file_path=file_path @classmethod def 阅读全文
posted @ 2018-04-10 12:44 夏晓旭 阅读(616) 评论(0) 推荐(0)
摘要: 类方法,静态方法,普通方法 #coding=utf-8 class Foo: def __init__(self,name): self.name=name def ord_func(self): print self.name print "normal function" @classmetho 阅读全文
posted @ 2018-04-10 12:44 夏晓旭 阅读(229) 评论(0) 推荐(0)
摘要: #coding=utf-8 class Person(object): id=12 def __init__(self,name): self.name=name self.__inName='ads' def __setId(self,id): Person.id=id*2 def getId(s 阅读全文
posted @ 2018-04-10 12:41 夏晓旭 阅读(166) 评论(0) 推荐(0)
摘要: what did you learn from your last class?20:09:07abc360.Draven/PHH-HA04 ☠ 2018/4/9 20:09:07poop20:12:42abc360.Draven/PHH-HA04 ☠ 2018/4/9 20:12:42its so 阅读全文
posted @ 2018-04-09 20:39 夏晓旭 阅读(336) 评论(0) 推荐(0)
摘要: #coding=utf-8import multiprocessing as mpimport time def consumer(cond): with cond: print "consumer before wait" cond.wait() print "consumer after wai 阅读全文
posted @ 2018-04-09 14:00 夏晓旭 阅读(299) 评论(0) 推荐(0)
摘要: #coding=utf-8import multiprocessing as mp def write_file(content,lock): lock.acquire() with open(r"d:\\0409.txt",'a') as fp: fp.write(content+'\n') lo 阅读全文
posted @ 2018-04-09 11:11 夏晓旭 阅读(2853) 评论(0) 推荐(0)