随笔分类 -  Python常用方法

上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页

收藏了一些好的文章以及教程 Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/), 是一种面向对象的解释型计算机程序设计语言,由荷兰人Guido van Rossum于1989年发明,第一个公开发行版发行于1991年。 Python是纯粹的自由软件, 源代码和解释器CPython遵循 GPL(GNU General Public License)协议[1] 。
conda 环境管理
摘要:conda介绍 conda 环境管理和virtualenv、pyenv的功能类似都是对python的环境管理器 coda用于科学计算更多一些,virtualenv、pyenv用于一般业务场景更多一些 coda下载地址国外地址下载较慢 推荐用清华源的下载地址 https://mirrors.tuna. 阅读全文

posted @ 2020-12-23 09:41 星河赵 阅读(192) 评论(0) 推荐(0)

python 协程 gevent安装
摘要:1.正常安装 pip install gevent 类似的安装错误 2.安装错误可以尝试 pip install pip setuptools wheel Cython==3.0.0a10 pip install gevent==20.9.0 --no-build-isolation 阅读全文

posted @ 2020-12-15 14:37 星河赵 阅读(843) 评论(0) 推荐(0)

python 实现生产者 消费者案例
摘要:题目:python起2个进程一个为生产者、一个为消费者(消费者进程中起协程消费) from multiprocessing import Process, Queue import time import random import gevent # 消费者方法 def consumer(q): w 阅读全文

posted @ 2020-11-27 22:19 星河赵 阅读(1154) 评论(0) 推荐(0)

python 之gevent 协程操作
摘要:gevent的简介 gevent是一个基于协程的python网络库,在遇到IO阻塞时,程序会自动进行切换,可以让我们用同步的方式写异步IO代码。 因为python线程的性能问题,在python中使用多线程运行代码经常不能达到预期的效果。而有些时候我们的逻辑中又需要开更高的并发,或者简单的说,就是让我 阅读全文

posted @ 2020-11-22 21:04 星河赵 阅读(1288) 评论(0) 推荐(0)

python 单例模式实现
摘要:Python单例模式实现 import settings import threading class TournamentRoomConfig(): """ 房间类 """ _instance_lock = threading.Lock() def __init__(self, room_id): 阅读全文

posted @ 2020-11-17 14:06 星河赵 阅读(142) 评论(0) 推荐(0)

Vue(项目配置iview的upload插件上传文件 )+ Python flask 上传文件
摘要:前端效果展示 前端代码 1、ivew upload组件 <Upload type="drag" // 支持拖拽 multiple // 支持多文件上传 :max-size="10240000" // 设置上传最大量 :action="'https://upload.qiniup.com'" // 七 阅读全文

posted @ 2020-09-24 16:26 星河赵 阅读(2181) 评论(0) 推荐(0)

uwsgi 常见配置
摘要:uwsgi常见配置 [uwsgi] master=true chdir=/home/op/gameserver_data # 项目目录地址 virtualenv=/home/op/gameserver_data/venv/ # 虚拟环境地址 wsgi-file=goldfinger.py plugi 阅读全文

posted @ 2020-08-27 16:45 星河赵 阅读(967) 评论(0) 推荐(1)

Supervisor进程组的使用
摘要:说明 因为后端服务一般我们会多开几个服务进程进行API接口的提供,在使用Supervisor进行进程管理的时候,会经常需要对相关进程进行管理。 所以我们可以把同一个相同的所属的进程组进行归类: 创建对应的需要包含的进程配置文件: [include] files = /etc/supervisor/c 阅读全文

posted @ 2020-07-28 18:23 星河赵 阅读(1696) 评论(0) 推荐(0)

Python 多线程、多进程、协成的使用
摘要:写在前面将列表分割供多进程、多线程使用 def list_fund(listTemp, n): """ 将列表平均分成N块 :param listTemp: :param n: :return: """ resules = [] for i in range(0, len(listTemp), n) 阅读全文

posted @ 2020-07-22 13:49 星河赵 阅读(348) 评论(0) 推荐(0)

curl 发送post请求
摘要:1. curl 发送post请求 curl http://127.0.2.1:5353/user/get_macro_data -X POST -d '{"num": "7"}' --header "Content-Type: application/json" 2.curl 发送post请求 js 阅读全文

posted @ 2020-06-04 14:04 星河赵 阅读(2694) 评论(0) 推荐(0)

python实现socketserver处理多连接 相关逻辑
摘要:1.收发字符串处理 # 接收字符处理 b转str # json_str = str(self.data, encoding="utf8") json_str = self.data.decode("utf-8") # 发送字符处理 str转b data.encode() 阅读全文

posted @ 2020-05-18 15:01 星河赵 阅读(484) 评论(0) 推荐(0)

使用supervisor 进行进程管理时调整最大文件打开数
摘要:[supervisord] logfile=/tmp/supervisord.log ; 日志文件,默认是 $CWD/supervisord.log logfile_maxbytes=50MB ; 日志文件大小,超出会 rotate,默认 50MB logfile_backups=10 ; 日志文件 阅读全文

posted @ 2020-04-30 11:30 星河赵 阅读(894) 评论(0) 推荐(0)

python str与bytes之间的转换
摘要:# bytes object b = b"example" # str object s = "example" # str to bytes bytes(s, encoding = "utf8") # bytes to str str(b, encoding = "utf-8") # an alt 阅读全文

posted @ 2020-04-27 19:01 星河赵 阅读(1593) 评论(0) 推荐(0)

Python 操作redis消息队列 多进程消费
摘要:生产端 import json import redis # 以下代码是向redis 发命令 QUEUE = "code" # 队列名称key # redisPool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db 阅读全文

posted @ 2020-04-21 10:31 星河赵 阅读(4757) 评论(0) 推荐(0)

Python 字典递归合并
摘要:Python 字典递归合并 def rec_merge(d1, d2): """ 递归合并字典 :param d1: {"a": {"c": 2, "d": 1}, "b": 2} :param d2: {"a": {"c": 1, "f": {"zzz": 2}}, "c": 3, } :retu 阅读全文

posted @ 2020-04-17 18:56 星河赵 阅读(1563) 评论(0) 推荐(0)

Python开发单元测试,必不可少
摘要:先介绍一下Python的单元测试常用框架 unittest pytest nose 下面重点介绍pytest 1. 概述 pytest是一个非常成熟的全功能的Python测试框架,主要特点有以下几点: 1、简单灵活,容易上手,文档丰富; 2、支持参数化,可以细粒度地控制要测试的测试用例; 3、能够支 阅读全文

posted @ 2020-03-19 17:49 星河赵 阅读(747) 评论(0) 推荐(0)

关于HTTP协议,所有内容都在这里,一篇就够了
摘要:HTTP简介 HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本地浏览器的传送协议。 HTTP是一个基于TCP/IP通信协议来传递数据(HTML 文件, 图片文件, 查询结果等) 阅读全文

posted @ 2020-03-19 17:38 星河赵 阅读(3280) 评论(0) 推荐(0)

安装uwsgi 报错“fatal error: Python.h: No such file or directory”
摘要:安装uwsgi 报错“fatal error: Python.h: No such file or directory” 一看找不到python.h,肯定是依赖问题,网上一搜,基本答案都是安装 python-dev 和 build-essential, 解决方法 apt-get install py 阅读全文

posted @ 2020-02-10 20:13 星河赵 阅读(1896) 评论(0) 推荐(0)

mongo 取随机100条数据写入Excel
摘要:Python 读取Mongo取随机100条数据写入Excel 阅读全文

posted @ 2019-12-29 17:37 星河赵 阅读(426) 评论(0) 推荐(0)

python实现RSA加密和签名以及分段加解密的方案
摘要:python实现RSA加解密和签名加解签 1、生成秘钥对 在这边为了方面演示,手动生成一个密钥对(项目中的秘钥对由开发来生成,会直接给到我们) 生成秘钥对的时候,可以指定生成秘钥的长度,一般推荐使用1024bit, 1024bit的rsa公钥,加密数据时,最多只能加密117byte的数据),数据量超 阅读全文

posted @ 2019-12-10 16:05 星河赵 阅读(1800) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页

导航