会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
zxy01
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
10
11
12
13
14
15
16
17
18
···
22
下一页
2020年12月14日
__slots__类属性限制
摘要: # __author: "ZXYang"# date: 2020/12/14class Test: # name = 'li' __slots__ = ['name', 'age', 'sex'] def num(self): passt = Test()t.name = 'li'"""__slot
阅读全文
posted @ 2020-12-14 23:07 zxy_ang
阅读(88)
评论(0)
推荐(0)
2020年12月13日
装饰器:添加参数(面试题)
摘要: # __author: "ZXYang"# date: 2020/12/13import time"""请设计一个装饰器,接收一个int类型的参数 number,可以用来装饰任何的函数如果函数运行的时间大于 number,则打甲出函数名和函数的运行时间(面试真题)"""def decorator01
阅读全文
posted @ 2020-12-13 21:22 zxy_ang
阅读(107)
评论(0)
推荐(0)
单例之装饰器
摘要: # __author: "ZXYang"# date: 2020/12/13def single(cls): dic = {} def wrapper(*args, **kwargs): if dic.get(cls): return dic[cls] else: dic[cls] = cls(*a
阅读全文
posted @ 2020-12-13 18:21 zxy_ang
阅读(71)
评论(0)
推荐(0)
单例
摘要: # __author: "ZXYang"# date: 2020/11/29"""__new__方法"""class Func(object): def __init__(self, name): self.name = name print("这是__init__方法") # new方法先执行 d
阅读全文
posted @ 2020-12-13 15:52 zxy_ang
阅读(64)
评论(0)
推荐(0)
__call__
摘要: # __author: "ZXYang"# date: 2020/12/13class MyTest(): def __call__(self, *args, **kwargs): print("__call__方法")m = MyTest()m()# __call__方法: m()可直接 【加()
阅读全文
posted @ 2020-12-13 11:19 zxy_ang
阅读(54)
评论(0)
推荐(0)
2020年12月12日
偏函数
摘要: # __author: "ZXYang"# date: 2020/12/12from functools import partialdef fun(a, b, c, d): print(a + b + c + d)# 固定函数的参数fun1 = partial(fun, 11, 22, 33)fu
阅读全文
posted @ 2020-12-12 17:49 zxy_ang
阅读(126)
评论(0)
推荐(0)
生成器
摘要: # __author: "ZXYang"# date: 2020/12/12"""yield生成器表达式:send, close, throwaa.close()print(aa.throw(ValueError))""" # a = (i*2 for i in range(10))## # pri
阅读全文
posted @ 2020-12-12 10:26 zxy_ang
阅读(86)
评论(0)
推荐(0)
2020年12月10日
zip
摘要: # __author: "ZXYang"# date: 2020/12/10a = [1, 2]b = [3, 4, 5]c = [6, 7, 8, 9]print(list(zip(a, b, c)))print(list(zip(c, b, a)))# [(1, 3, 6), (2, 4, 7)
阅读全文
posted @ 2020-12-10 22:14 zxy_ang
阅读(107)
评论(0)
推荐(0)
reduce
摘要: # __author: "ZXYang"# date: 2020/12/10from functools import reducenums = [1, 2, 3, 4, 5]print(reduce(lambda x, y: x + y, nums, 100))print(reduce(lambd
阅读全文
posted @ 2020-12-10 22:07 zxy_ang
阅读(117)
评论(0)
推荐(0)
2020年12月9日
map
摘要: # __author: "ZXYang"# date: 2020/12/9a = [1, 2, 3, 4, 5]def s(a1): return a1 + 10# 将a作为迭代值传入函数sprint(list(map(s, a)))
阅读全文
posted @ 2020-12-09 23:25 zxy_ang
阅读(25)
评论(0)
推荐(0)
上一页
1
···
10
11
12
13
14
15
16
17
18
···
22
下一页
公告