10 2021 档案
摘要:# super(type[, object-or-type]) ,调用父类方法class FooParent(object): def __init__(self): self.parent = 'I\'m the parent.' print ('Parent') def bar(self, me
阅读全文
摘要:# -*- coding:utf-8 -*-# @staticmethod和@classmethod的用法"""一般来说,要使用某个类的方法,需要先实例化一个对象再调用方法,而使用@staticmethod或@classmethod,就可以不需要实例化,直接类名.方法名()来调用。既然如此,那他们俩
阅读全文
摘要:作用: 我们可以使用@property装饰器来创建只读属性,@property装饰器会将方法转换为相同名称的只读属性,可以与所定义的属性配合使用,这样可以防止属性被修改。 使用场景: 1.修饰方法,是方法可以像属性一样访问。 class DataSet(object): @property def
阅读全文
摘要:# -*- coding:utf-8 -*-# 学习装饰器的一些常用场景from functools import wrapsdef decorator_name(f): @wraps(f) def decorated(*arg, **kwargs): if not can_run: return(
阅读全文
摘要:# -*- coding:utf-8 -*-"""一切皆对象"""def hi(name='mecexia'): return "hi " + nameprint(hi())# 将一个函数赋值给一个变量greet = hi # 这里没有使用小括号,因为并不是要调用hi函数,而是要定义一个greet函
阅读全文
摘要:1、通过openssl生成私钥 openssl genrsa -out server.key 1024 2、根据私钥生成证书申请文件csr openssl req -new -key server.key -out server.csr 3、这里根据命令行向导来进行信息输入: 4、使用私钥对证书申请
阅读全文