上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 19 下一页
摘要: 一:调用区别 class Demo(object): @staticmethod def static_method(): return "static_method" @classmethod def instance_method(self): return "instance_method" 阅读全文
posted @ 2020-04-03 15:55 张京墨 阅读(1547) 评论(0) 推荐(0) 编辑
摘要: 一:处理404错误 # flask自己抓取404错误,定义函数专门处理404错误 @app.errorhandler(404) def err_404(err): return "你要的页面飞到外太空了" 好处:统一管理同类型错误,并可以指定函数进行处理 阅读全文
posted @ 2020-04-02 22:40 张京墨 阅读(316) 评论(0) 推荐(0) 编辑
摘要: app.py from flask import Flask,jsonify app = Flask(__name__) app.route("/index") def index(): print("进入函数") return "hello world" if __name__ == '__mai 阅读全文
posted @ 2020-03-31 00:03 张京墨 阅读(836) 评论(0) 推荐(0) 编辑
摘要: 一:echo 将echo 后面的字符串输出 假如我们想看看 ifcofnig里面的内容 echo ifconfig:并没有显示我们想看到的效果 echo `ifconfig` 而不是 echo "ifconfig" 来显示config里面的内容 可是格式不对,看着别扭 echo "`ifconfig 阅读全文
posted @ 2020-03-29 16:33 张京墨 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 一:什么是 supervisor 超级用户,监管员的意思,Supervisor是一个进程管理工具,当进程中断的时候Supervisor能自动重新启动它。可以运行在各种类unix的机器上,supervisor就是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon( 阅读全文
posted @ 2020-03-28 17:46 张京墨 阅读(540) 评论(0) 推荐(0) 编辑
摘要: 单例模式代码 mysql_test.py from functools import wraps import pymysql def single(cls): """实现类的单例模式""" instance_dict = dict() @wraps(cls) def single_instance 阅读全文
posted @ 2020-03-25 17:53 张京墨 阅读(1056) 评论(0) 推荐(0) 编辑
摘要: 一:celery 作用:celery能后执行异步操作,可以去执行耗时的函数,也可以用来做定时调度 例如:发短信,消息推送,音视频处理 普通函数 import time def add(x, y): print("进入函数") time.sleep(5) return x + y if __name_ 阅读全文
posted @ 2020-03-17 17:09 张京墨 阅读(853) 评论(1) 推荐(0) 编辑
摘要: 一:gevent模块 import gevent def f(n): for i in range(n): print(gevent.getcurrent(), i) # 创建一个普通的greenlet对象,并进行切换 g1 = gevent.spawn(f, 5) g2 = gevent.spaw 阅读全文
posted @ 2020-03-17 15:15 张京墨 阅读(401) 评论(0) 推荐(0) 编辑
摘要: 数据样例 { "_id" : ObjectId("5e67343f00850012ec08ad3e"), "river" : [ "长江", "黄河", "淮河" ] } { "_id" : ObjectId("5e67343f00850012ec08ad3f"), "river" : [ "长江" 阅读全文
posted @ 2020-03-10 15:35 张京墨 阅读(2292) 评论(0) 推荐(0) 编辑
摘要: pymongo的聚合操作 数据类型样式 /* 1 */ { "_id" : ObjectId("5e5a32fe2a89d7c2fc05b9fc"), "user_id" : "1", "amount" : 500, "status" : "A" } /* 2 */ { "_id" : Object 阅读全文
posted @ 2020-02-29 20:13 张京墨 阅读(5975) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 19 下一页