该文被密码保护。 阅读全文
posted @ 2020-04-15 21:16
阿木木的木
阅读(2)
评论(0)
推荐(0)
摘要:
在用django写项目时,项目中经常会有地方要判断用户是否登陆。不做特殊处理每次都要去session,cookie中取了做判断, 可以利用django中间件设置黑白路由名单,进行判断,代码简单,写一次就可以了。 # 用户登陆验证及操作时的的白名单设置,中间件。from django.utils.de 阅读全文
posted @ 2020-04-15 21:05
阿木木的木
阅读(62)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-04-15 20:50
阿木木的木
阅读(2)
评论(0)
推荐(0)
摘要:
python的遍历在程序中很重要,详细了解一下遍历模式,可以应用于任务分发,数据的读写中。 python的 递归遍历目录: import osdef getAllDirRE(path, sp = ""): #得到当前目录下所有的文件 filesList = os.listdir(path) #处理每 阅读全文
posted @ 2020-04-15 20:42
阿木木的木
阅读(227)
评论(0)
推荐(0)
摘要:
作者:割肉机 参考:https://www.cnblogs.com/williamjie/p/11187503.html Python读写文件 1.open 使用open打开文件后一定要记得调用文件对象的close()方法。比如可以用try/finally语句来确保最后能关闭文件。 file_obj 阅读全文
posted @ 2020-04-15 20:32
阿木木的木
阅读(137)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-04-15 20:27
阿木木的木
阅读(0)
评论(0)
推荐(0)
摘要:
linux下创建虚拟环境: python -m venv .venv(虚拟环境名字) 创建虚拟环境 source .venv/bin/activate 激活虚拟环境 which python 查看Python是否是虚拟环境下的 deactivate 退出虚拟环境 windows git bash下创 阅读全文
posted @ 2020-04-15 20:07
阿木木的木
阅读(321)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-04-15 19:55
阿木木的木
阅读(1)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-04-15 19:30
阿木木的木
阅读(0)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-04-15 19:25
阿木木的木
阅读(1)
评论(0)
推荐(0)
摘要:
零、linux中安装设置 启动redis service redis start 停止redis service redis stop 查看状态 service redis status/systemctl status redis 查看进程 ps -ef | grep redis 设置开机启动 c 阅读全文
posted @ 2020-04-15 19:20
阿木木的木
阅读(738)
评论(0)
推荐(0)
摘要:
0、linux中mariadb linux上安装Mariadb设置参考 : https://www.cnblogs.com/keithtt/p/6922378.html 开启服务 systemctl start mariadb 查看服务 systemctl status mariadb 停止服务 s 阅读全文
posted @ 2020-04-15 19:18
阿木木的木
阅读(491)
评论(0)
推荐(0)
摘要:
实现单例模式,及python程序在调用某一个类的时候,永远只出现一个实例(可以节约内存,CPU): 1,通过包的形式写在外面以import的形式导入,最直接。 2,以__new__方法创建单例模式,代码如下: class Singleton(object): def __init__(self): 阅读全文
posted @ 2020-04-15 17:49
阿木木的木
阅读(204)
评论(0)
推荐(0)
摘要:
django中创建cache.py,写如下代码from redis import Redis from django.conf import settings class MSRedis(object): '''读写分离客户端(只针对程序中用到的命令)''' def __init__(self,co 阅读全文
posted @ 2020-04-15 17:22
阿木木的木
阅读(444)
评论(1)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-04-15 17:01
阿木木的木
阅读(226)
评论(0)
推荐(0)

浙公网安备 33010602011771号