随笔分类 -  Python - 模块

摘要:""" pip install aioredis """ import asyncio import aioredis async def execute(address, password): redis = await aioredis.create_redis(address, passwor 阅读全文
posted @ 2020-05-23 12:07 慕沁
摘要:asyncio.Future(*, loop=None) 几乎兼容concurrent.futures.Future result()并且exception()不要接受超时参数,并且在未来还没有完成时引发异常。 add_done_callback()始终通过事件循环的调用注册到的回调call_soo 阅读全文
posted @ 2020-05-21 21:31 慕沁
摘要:import concurrent.futures def download_one(url): pass def download_all(sites): with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: 阅读全文
posted @ 2020-05-21 21:15 慕沁
摘要:fire是python中用于生成命令行界面(Command Line Interfaces, CLIs)的工具,不需要做任何额外的工作,只需要从主模块中调用fire.Fire(),它会自动将你的代码转化为CLI,Fire()的参数可以说任何的python对象 用法1 import fire def 阅读全文
posted @ 2020-05-19 11:37 慕沁
摘要:# for 遍历对象时: # 1、调用__iter__ # 2、__getitem__,会依次传入0->正无穷 # len 遍历对象时: x = Company(['a', 'b', 'c']) # for i in x[1:2]: # print(i) from collections.abc i 阅读全文
posted @ 2020-02-24 14:45 慕沁
摘要:当使用logstash中 tcp输入时,获取日志内容。 import logging from logging.handlers import DatagramHandler, HTTPHandler import logstash import sys host = '192.168.9.61' 阅读全文
posted @ 2020-02-01 16:56 慕沁
摘要:提供了非常灵活、丰富的时间日期格式化方法。在模板中,可以通过对moment类调用format方法来格式化时间和日期,moment的构造方法接收使用utcnow方法创建的datetime对象作为参数,即message对象的timestamp属性。format方法接收特定的格式字符串来渲染时间格式。 时 阅读全文
posted @ 2019-12-30 18:08 慕沁
摘要:''' pip install aiomysql ''' import aiomysql # from tornado import ioloop import asyncio async def test_example(): pool = await aiomysql.create_pool(h 阅读全文
posted @ 2019-12-02 16:47 慕沁
摘要:peewee是一款ORM详细文档:https://peewee.readthedocs.io/en/latest/index.html from peewee import * from datetime import date database = MySQLDatabase('peewee_te 阅读全文
posted @ 2019-12-02 16:37 慕沁
摘要:import argparse def main(args): print(args) if '__main__' == __name__: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--re 阅读全文
posted @ 2019-11-24 18:55 慕沁
摘要:import chardet data = 'asdasdcxz阿萨德'.encode('gbk') print(data) s = chardet.detect(data) print(s) b'asdasdcxz\xb0\xa2\xc8\xf8\xb5\xc2' {'encoding': 'IS 阅读全文
posted @ 2019-11-18 21:38 慕沁
摘要:1、jwt认证流程 传统token方式和jwt认证方式有什么差异? 2、jwt创建token 2.1、原理 2.2代码实现 3、JWT校验token JSON Web Tokens ,是一种开发的行业标准RFC 7519 ,用于安全的表示双方之间的声明。 1、jwt认证流程 传统token方式和jw 阅读全文
posted @ 2019-11-14 16:56 慕沁
摘要:pip install wmiwin 可用 依赖win32系列模块 阅读全文
posted @ 2019-05-08 10:03 慕沁
摘要:from lxml import etree wb_data = """ <div> <ul> <li class="item-0"><a href="link1.html">first item</a></li> <li class="item-1"><a href="link2.html">se 阅读全文
posted @ 2019-04-13 11:42 慕沁
摘要:import pymongo from bson import ObjectId mongo_client = pymongo.MongoClient(host="127.0.0.1",port=27017) MONGO = mongo_client["s14day120"] # 查询数据 # res = list(MONGO.user_info.find({})) # print(res)... 阅读全文
posted @ 2019-04-06 14:51 慕沁
摘要: 阅读全文
posted @ 2019-04-06 11:44 慕沁
摘要:pycrypto,pycrytodome和crypto是一个东西,在很久以前,crypto在python上面的名字是pycrypto它是一个第三方库,但是已经停止更新三年了,所以不建议安装这个库; windows下python3.6安装也不会成功! 这个时候pycryptodome就来了,它是pycrypto的延伸版本,用法和pycrypto 是一模一样的; 重点: 直接pip install ... 阅读全文
posted @ 2019-04-06 09:49 慕沁
摘要:# -*- coding: utf-8 -*- from openpyxl import load_workbook from openpyxl import Workbook from openpyxl.chart import (PieChart , ProjectedPieChart, Ref 阅读全文
posted @ 2019-04-04 11:49 慕沁
摘要:''' pip3 install pillow pil 库支持图像的存储、显示、和处理,能够处理几乎所有的图片格式,可以完成对图像的缩放、裁剪、才见你以及向图像添加线条和文字等操作 pil 库主要实现图像归档和图像处理两方面的功能需求 根据不同的功能,PIL包括21个与图像相关的类, ''' # ######################################Image模块#... 阅读全文
posted @ 2019-03-06 20:57 慕沁
摘要:'''pip3 install qrcode''' import qrcode img = qrcode.make('asfdagasdfasd') img.save('123.png') ''' version=None, error_correction=constants.ERROR_CORRECT_M, box_size=10, border=4, image_factory=N... 阅读全文
posted @ 2019-03-06 20:35 慕沁