1 2 3 4 5 ··· 19 下一页
摘要: 当一个class 中定义了__get__, __set__, __delete__三个函数中的任意一个,那么这个class就可以被成为描述符。当在python中使用点 . 来调用某个属性的时候,其load attr的顺序如下图所示。 关于描述符中instance 和owner的解释 class Na 阅读全文
posted @ 2024-06-23 14:53 朵朵奇fa 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2024-06-20 17:38 朵朵奇fa 阅读(2) 评论(0) 推荐(0) 编辑
摘要: class f1: def __init__(self): self.name = "f1" def printF1(self): print("this is f1") class f2: def __init__(self): self.name = "f2" def printF2(self) 阅读全文
posted @ 2024-06-20 17:16 朵朵奇fa 阅读(2) 评论(0) 推荐(0) 编辑
摘要: class TestInstance: def __init__(self): # 初始化库字典,存放找到的库 self.lib = Proxy() # 使用一个代理对象来模拟层级结构 class Proxy: def __init__(self): self._libObjectDictCache 阅读全文
posted @ 2024-04-27 20:47 朵朵奇fa 阅读(33) 评论(0) 推荐(0) 编辑
摘要: def list_submodules(self,package_path): """递归地列出给定包路径下的所有子模块""" all_submodules = [] # 遍历包路径下的所有文件/目录 for importer, modname, ispkg in pkgutil.iter_modu 阅读全文
posted @ 2024-03-10 20:27 朵朵奇fa 阅读(73) 评论(0) 推荐(0) 编辑
摘要: import importlib.util def import_module_by_path(module_path,module_name): """ 根据给定的完整路径动态导入模块 """ spec = importlib.util.spec_from_file_location(module 阅读全文
posted @ 2024-03-10 20:26 朵朵奇fa 阅读(132) 评论(0) 推荐(0) 编辑
摘要: # testInstance.py # 导入需要的模块 import importlib # 导入模块以动态加载库中的类和函数 import sys # 导入系统模块,用于操作Python解释器的参数和变量 # 定义TestInstance类 class TestInstance: # 初始化方法, 阅读全文
posted @ 2024-03-03 22:06 朵朵奇fa 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 /** * Note: The returned array must be malloced, assume caller calls free(). */ int cmp(const void * a, const void * b) 阅读全文
posted @ 2023-09-26 17:35 朵朵奇fa 阅读(7) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int main () { char* s = "hello"; // 字符串名字就是首地址 printf("%x\n",s); // s是char指针,size = 4 or 8 printf("sizeof s is %d\n", sizeof(s)); / 阅读全文
posted @ 2023-09-26 17:01 朵朵奇fa 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 167. 两数之和 II - 输入有序数组 - 力扣(LeetCode) /** * Note: The returned array must be malloced, assume caller calls free(). */ int* twoSum(int* numbers, int num 阅读全文
posted @ 2023-09-26 14:50 朵朵奇fa 阅读(6) 评论(0) 推荐(0) 编辑
1 2 3 4 5 ··· 19 下一页