文章分类 -  Python

摘要:# coding=utf-8 import os import json import connexion from flask import jsonify app = connexion.FlaskApp(__name__, specification_dir='.') application = app.app # 测试配置 # application.config['SQLA... 阅读全文
posted @ 2019-04-13 15:27 Adamanter 阅读(358) 评论(0) 推荐(0)
摘要:# python3.6# coding=utf-8words = "\u9a8c\u8bc1\u7801\u68c0\u67e5\u6210\u529f"print(words, type(words))# 验证码检查成功 <class 'str'>words = b"\u9a8c\u8bc1\u7 阅读全文
posted @ 2019-04-13 15:06 Adamanter 阅读(432) 评论(0) 推荐(0)
摘要:app文件夹下: task_timed_del_post.py timed_del_post函数在task_timed_del_post.py 更简单点的: 阅读全文
posted @ 2019-04-11 18:21 Adamanter 阅读(2400) 评论(0) 推荐(0)
摘要:我自己Mac: brew install ctags # 依赖安装 wget http://blog.zyan.cc/soft/linux/webbench/webbench-1.5.tar.gz tar -zxvf webbench-1.5.tar.gz cd webbench-1.5 mkdir 阅读全文
posted @ 2019-03-28 21:55 Adamanter 阅读(172) 评论(0) 推荐(0)
摘要:def detect_legal_phone(phone_number): if phone_number == None or phone_number == "": return False if len(phone_number) != 11: return False for c in phone_number: i... 阅读全文
posted @ 2019-03-26 18:18 Adamanter 阅读(3094) 评论(0) 推荐(0)
摘要:version > python3.5 tags = [{"value": "A", "key": "hello"},{"value": "A", "key": "world"}] b = OrderedDict() for item in tags: b.setdefault(item['valu 阅读全文
posted @ 2019-03-26 16:34 Adamanter 阅读(1160) 评论(0) 推荐(0)
摘要:开启uwsgi的web服务 uwsgi --http :20001 -w app.main 杀掉uwsgips -ef | grep 20001 | awk '{print $2}' | xargs kill -9 阅读全文
posted @ 2019-03-25 17:00 Adamanter 阅读(1883) 评论(0) 推荐(0)
摘要:uwsgi --http :20002 -w app.main 杀掉端口为20002 ps -ef | grep 20002 | awk '{print $2}' | xargs kill -9 杀掉uwsgi: ps -ef | grep uwsgi | awk '{print $2}' | xa 阅读全文
posted @ 2019-03-22 10:47 Adamanter 阅读(247) 评论(0) 推荐(0)
摘要:情景以及定位慢处: 数据从30万到240万,原来查询post,现在查询GalleryPostposts,原来: 慢原来显示: posts = Post.objects(tags__all=tags).order_by('-id').limit(per_page) _user_ids = list(m 阅读全文
posted @ 2019-03-19 11:14 Adamanter 阅读(933) 评论(0) 推荐(0)
摘要:# 场景:一次取回mongodb某表-64万数据,pymongo.errors.DocumentTooLarge: BSON document too large (28888095 bytes) - # the connected server supports BSON document sizes up to 16777216 bytes. 文档太大就无法返回,因此分10次取,每次 # ... 阅读全文
posted @ 2019-03-09 14:51 Adamanter 阅读(1923) 评论(0) 推荐(0)
摘要:注意插入数字也是%s 阅读全文
posted @ 2019-03-07 21:09 Adamanter 阅读(3636) 评论(0) 推荐(0)
摘要:from mongoengine.connection import get_db, connect from pymongo import MongoClient, ASCENDING, UpdateOne, InsertOne, DeleteOne, ReplaceOne from pymongo.errors import BulkWriteError # pymongo建立索引... 阅读全文
posted @ 2019-03-07 20:50 Adamanter 阅读(4498) 评论(0) 推荐(0)
摘要:__gt 大于 __gte 大于等于 __lt 小于 __lte 小于等于 __in 存在于一个list范围内 __startswith 以...开头 __istartswith 以...开头忽略大小写 __endswith 以...结尾 __iendswith 以...结尾,忽略大小写 __range 在...范围内 __year... 阅读全文
posted @ 2018-11-01 16:58 Adamanter 阅读(1597) 评论(0) 推荐(0)
摘要:原因一: 环境:python2.7 报错:UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128) 方案: 原因二: Linux-ubuntu-uwsgi 阅读全文
posted @ 2018-09-29 19:52 Adamanter 阅读(588) 评论(0) 推荐(0)
摘要:一般来说,增删改查的测试可以作为一个流程,那么删除就要放到最后测,因此称为增查改删。 以数据集的增查改删除为例简单了解一下业务,通过数据库建表来了解我们需要的操作。 Mongodb的python mongoengine ORM建表 1 # -*- coding: utf-8 -*- 2 3 impo 阅读全文
posted @ 2018-09-29 11:58 Adamanter 阅读(1325) 评论(0) 推荐(0)
摘要:位置参数 && 默认参数 && 关键字参数 && *位置参数 &&**关键字参数 位置参数:调用函数时所传参数的位置必须与定义函数时参数的位置相同,比如name,age 关键字参数:使用关键字参数会指定参数值赋给哪个形参,调用时所传参数的位置可以任意,后面必须是变量,不传就没有比如data="hel 阅读全文
posted @ 2018-09-17 16:18 Adamanter 阅读(245) 评论(0) 推荐(0)
摘要:1 datetime 2 简单封装以及获取毫秒级别时间差和微秒级别时间差 阅读全文
posted @ 2018-05-26 17:22 Adamanter 阅读(21398) 评论(0) 推荐(0)
摘要:简单多线程返回结果: 阅读全文
posted @ 2017-09-29 23:44 Adamanter 阅读(1913) 评论(0) 推荐(0)
摘要:队列:管道或者巷子,先进先出 队列的生产者消费者模型 栈:后进先出或者先进后出 阅读全文
posted @ 2017-09-21 15:36 Adamanter 阅读(239) 评论(0) 推荐(0)
摘要:客户端 服务端 基于select模块实现io多路复用 阅读全文
posted @ 2017-09-21 15:29 Adamanter 阅读(137) 评论(0) 推荐(0)