会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
xusuns
博客园
首页
新随笔
联系
订阅
管理
1
2
3
4
5
下一页
2019年4月10日
学习笔记,单例
摘要: class test(object): flog = None flog1 = False def __new__(cls, *args, **kwargs): if cls.flog is None: cls.flog = super().__new__(cls) return cls.flog def...
阅读全文
posted @ 2019-04-10 16:22 xusuns
阅读(102)
评论(0)
推荐(0)
2019年4月7日
有关类方法属性,静态方法,实例方法属性
摘要: class Game(): # 这是个类属性 top_fen = 0 @classmethod # 这是类方法 def show_top_fen(cls): print("最高分是%d,这是个类方法" % cls.top_fen) @staticmethod # 这是个静态方法 def show_help(): ...
阅读全文
posted @ 2019-04-07 10:22 xusuns
阅读(133)
评论(0)
推荐(0)
2019年3月31日
学习笔记,类,士兵突击
摘要: class Gun(): def __init__(self, gun_name, bullet=0): self.gun_name = gun_name self.bullet = bullet def __str__(self): return "[%s]子弹数[%d]" % (self.gun_name, self.bull...
阅读全文
posted @ 2019-03-31 12:10 xusuns
阅读(136)
评论(0)
推荐(0)
2019年3月29日
学习笔记,做一个添加家具的操作
摘要: 学习笔记,做一个添加家具的操作
阅读全文
posted @ 2019-03-29 15:51 xusuns
阅读(175)
评论(0)
推荐(0)
2018年3月12日
用装饰器做一个登陆系统
摘要: 主页分为四个板块:原创软件,精品软件,灌水专区,福利专区。原创软件,精品软件可以浏览,灌水专区,福利专区需要登陆后浏览,支持qq登陆和本地登陆两种方式,用户系统支持增删改查功能(学习完正则之后再修改),需要留用户名密码手机三个 选项。
阅读全文
posted @ 2018-03-12 15:33 xusuns
阅读(307)
评论(0)
推荐(0)
2018年2月27日
用生成器做斐波那契数列
摘要: def f(max): n, a, b = 0, 0, 1 while n <= max: yield b a, b = b, a + b n += 1 yield 'done' for i in f(5): print(i)
阅读全文
posted @ 2018-02-27 10:52 xusuns
阅读(361)
评论(0)
推荐(0)
2018年2月14日
装饰器函数
摘要: def bett(f): def inner(): print('123') f() print('hello') return inner @bett def f(): print('abc') f()
阅读全文
posted @ 2018-02-14 21:28 xusuns
阅读(75)
评论(0)
推荐(0)
2018年2月6日
文件操作,是一个存为字符串格式的登陆系统,有增删改查的功能,但不是我想要的。。。
摘要: def register(NAME, PWD, TEL): with open('userdate.txt', 'a', encoding='utf-8') as f: new = '&&'.join([NAME, PWD, TEL]) f.write('\n' + str(new)) return True def same(NAME): ...
阅读全文
posted @ 2018-02-06 14:35 xusuns
阅读(174)
评论(0)
推荐(0)
2018年2月4日
做一个登陆的文件操作,存到文件中是一个字典的形式{name:[pwd,tel]},为啥会报错 ?请指点
摘要: def register(name, pwd, tel): with open('userdate.txt', 'a', encoding='utf-8') as f: new = {} new[name] = [pwd,tel] f.write('\n' + str(new)) return True def same...
阅读全文
posted @ 2018-02-04 10:34 xusuns
阅读(247)
评论(0)
推荐(0)
2018年1月31日
冒泡排序
摘要: a = [18, 33, 98, 5, 2, 7, 2, 1] for i in range(len(a) - 1): # 总比对轮数,最后一次不用比对 for j in range(len(a) - i - 1): # 每轮的比对次数,已经比对过的不用再次比对 if a[j] < a[j + 1]: # 如果满足条件(前一个数大) a[j]...
阅读全文
posted @ 2018-01-31 15:53 xusuns
阅读(100)
评论(0)
推荐(0)
1
2
3
4
5
下一页
公告