![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
python
yaos829
这个作者很懒,什么都没留下…
展开
-
Python flask 多线程 logging 导致进程变慢和 TimedRotatingFileHandler 缺少日志
Python logging是不太支持多线程的,要不然可能会重复写很多日志使进程变慢。这里选择 QueueHandler 和 QueueListener 处理 flask 日志,其他线程调用 QueueHandler 往queue里发送日志消息,启动一个监听线程 QueueListener 调用 TimedRotatingFileHandler 从queue里获取日志消息,往日志文件里写日志。import queueimport loggingfrom logging.handlers import原创 2020-09-23 12:12:26 · 1762 阅读 · 0 评论 -
python 字典的key没有引号,怎么使用这个字典。
result = { TopicPartition(topic='CLEAR', partition=1): [ ConsumerRecord(topic='CLEAR', partition=1, offset=195, value=b'\x01\x00com.js.trade.directive.RtnOrde\xf')], checksum=None, serialized_key...原创 2020-04-16 14:52:03 · 4345 阅读 · 0 评论 -
亚马逊 s3 boto3 中 Client,Resource和Session 区别。
boto3 中 Client,Resource和Session的不同。boto3 英文官方文档链接 https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.htmlResource 是 Amazon Web Services(AWS)的面向对象的接口。 与 Client 进行的原始低级调用相比,它们提供了面...原创 2019-12-20 19:31:53 · 5549 阅读 · 0 评论 -
python小技巧
使用enumerate代替rangeenumerate函数提供了一种精简的在遍历元素时候获取每个索引的写法,在代码中尽可能用enumerate代替传统上的range与下标访问相结合的序列遍历代码seasons = ['Spring', 'Summer', 'Fall', 'Winter']list(enumerate(seasons))>>>[(0, 'Spring'...原创 2019-12-18 11:45:47 · 92 阅读 · 0 评论 -
python简单协程使用示例
使用示例创建协程:coroutine = func()。创建事件循环:loop = asyncio.get_event_loop()。创建task:task = loop.create_task(coroutine)。将协程变成task。新建task的状态为pending。(可以将loop.create_task()和loop.ensure_future()视为同等作用。启动task:lo...原创 2019-12-18 11:43:06 · 352 阅读 · 0 评论 -
使用 openpyxl 获取Excel总列数,总行数,获取一行所有值,获取一列所有值。
使用 openpyxl 获取Excel总列数,总行数,获取一行所有值,获取一列所有值。from openpyxl import *class ExcelOp(object): def __init__(self, file): self.file = file self.wb = load_workbook(self.file) sh...原创 2019-12-18 11:40:43 · 34516 阅读 · 7 评论