链式
class person:
def name(self,name):
self.name = name
return self
def age(self,age):
self.age = age
return self
def show(self):
print(f"my name is {self.name},and i am {self.age}")
装饰器
- 函数装饰器
def print_args(function):
def wrapper(*args,**kwargs):
print(f"function => {function.__name__};argument => {args},{kwargs}")
return function(*args,**kwargs)
return wrapper
bool value is false
False None 0 "" () [] {}
these bool values are false. you can use when needing to judge var if was empty
if not a:
...
随机获取list值
a = [1,2,3,4]
random.choice(a)
``
网友评论