上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 81 下一页
摘要: 转自:https://blog.csdn.net/yilulvxing/article/details/85374142 子类:Son类父类:Father类以下案例均表示Son类继承父类的一些属性和初始化参数构造等。 5个模块: (1):直接调用父类属性方法; (2):重写父类属性方法; (3):强 阅读全文
posted @ 2020-04-20 14:37 Mars.wang 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 转自:https://github.com/chaseSpace/IPC-Inter-Process-Communication 六种进程间通信方式的Python3.6代码实现 msg_queue (消息队列) pipeline for single duplex (单工管道) pipeline f 阅读全文
posted @ 2020-04-09 19:53 Mars.wang 阅读(318) 评论(0) 推荐(1) 编辑
摘要: Python中进行并发编程一般使用threading和multiprocessing模块,不过大部分的并发编程任务都是派生一系列线程,从队列中收集资源,然后用队列收集结果。在这些任务中,往往需要生成线程池,concurrent.futures模块对threading和multiprocessing模 阅读全文
posted @ 2020-04-09 18:11 Mars.wang 阅读(570) 评论(0) 推荐(0) 编辑
摘要: 有些时候我们会遇到这样的需求,需要删除某个目录,但这个目录下有个别的文件或文件夹需要保留 下面这个脚本就是用来处理这类问题 # #针对大目录下保留部分子目录的程序化处理方案 # 1.从大目录列出下一级目录,匹配是否是需要保留的子目录的前缀,如果不是,保存到待删除dir_list # 2.如果是父目录 阅读全文
posted @ 2020-04-09 17:05 Mars.wang 阅读(1145) 评论(1) 推荐(0) 编辑
摘要: from multiprocessing.pool import Pool import boto3 import os client = boto3.client('s3') response = client.list_buckets() buckets = response['Buckets' 阅读全文
posted @ 2020-04-07 13:45 Mars.wang 阅读(622) 评论(1) 推荐(0) 编辑
摘要: 在正常的python多进程中,父进程只负责将任务分发给子进程,子进程成功与否,父进程并不关心. 但是在生产环境中,这种显然是不恰当的.通过研究我发现通过回调方法可以获取子进程的状态,然后通过一个queue将失败的子进程标记出来,就可以实现失败进程的重试,代码如下: import queue impo 阅读全文
posted @ 2020-04-03 16:44 Mars.wang 阅读(4157) 评论(0) 推荐(0) 编辑
摘要: 备注:我的Mac电脑ctrl和command进行了交换 0.编辑 ctrl+F:搜索 ctrl+R:替换 command+shift+F:全局搜索 command+shift+R:全局替换 ctrl+D:复制行 ctrl+shift+U:切换大小写 ctrl+w:扩大选择 alt+F7:查找使用处 阅读全文
posted @ 2020-03-23 17:23 Mars.wang 阅读(494) 评论(0) 推荐(0) 编辑
摘要: 从3.7版本开始,python提供了 data 类。与常规类或其他替代方法(如返回多个值或字典)相比,有以下几个优点: 数据类需要至少一定数量的代码 可以通过 eq 方法来比较不同的data类对象 可以 repr 通过很容易地打印一个数据类来进行调试 数据类需要类型提示,因此减少了 bug 一个da 阅读全文
posted @ 2020-03-23 16:20 Mars.wang 阅读(606) 评论(0) 推荐(0) 编辑
摘要: class Test(): xx = False def __init__(self): pass def test(func): def wrapper(self, *args, **kwargs): print(self.xx) return func(self, *args, **kwargs 阅读全文
posted @ 2020-03-03 13:50 Mars.wang 阅读(1283) 评论(0) 推荐(1) 编辑
摘要: class Person(): __instance=None @classmethod def get_instance(cls): if cls.__instance: return cls.__instance else: cls.__instance=Person() return cls.__instance if __name__=='__main__': p1=Person.get_ 阅读全文
posted @ 2019-12-25 20:12 Mars.wang 阅读(117) 评论(0) 推荐(0) 编辑
上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 81 下一页