会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
半日闲1
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
6
7
8
9
10
11
12
13
14
···
19
下一页
2021年3月15日
paramiko模块
摘要: ssh登录与证书登录实现 import paramiko from paramiko.ssh_exception import AuthenticationException def ssh_channel(connect_type=True): ssh_client = paramiko.SSHC
阅读全文
posted @ 2021-03-15 21:53 半日闲1
阅读(84)
评论(0)
推荐(0)
2021年3月7日
列表转json数据返回
摘要: 设置参数 def fun(request): data = [ { "name": "tes3", "id": 12, "ip": "10.10.12.120, 10.10.12.121" }, { "name": "test2", "id": 13, "ip": "10.10.12.1,10.10
阅读全文
posted @ 2021-03-07 22:51 半日闲1
阅读(114)
评论(0)
推荐(0)
2021年3月3日
socket模块判断ip加端口的连通性
摘要: 1 def check_connect(host, port): 2 sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 3 sk.settimeout(2) 4 status = 0 5 try: 6 sk.connect((host, p
阅读全文
posted @ 2021-03-03 20:04 半日闲1
阅读(253)
评论(0)
推荐(0)
2021年3月2日
Django 日志
摘要: 例:setting配置 import logging import os # LOG_DIR = "/var/log/dt_logs" LOG_DIR = "./" # if not os.path.exists(LOG_DIR): # os.mkdir(LOG_DIR) LOGGING = { "
阅读全文
posted @ 2021-03-02 20:15 半日闲1
阅读(59)
评论(0)
推荐(0)
python 时间模块
摘要: datetime 模块中 常用 second 和 total_seconds() 来获取时间差 seconds 忽略天 只看时分秒 total_seconds() 真正的时间差 包含天 1. 模型创建时间字段 create_time = models.DateTimeField("创建时间", nu
阅读全文
posted @ 2021-03-02 20:12 半日闲1
阅读(58)
评论(0)
推荐(0)
2021年3月1日
中间件
摘要: 视图函数 中间件类 class JsonMiddleware(MiddlewareMixin): def process_response(self, request, response): if isinstance(response, HttpResponse): return response
阅读全文
posted @ 2021-03-01 21:28 半日闲1
阅读(52)
评论(0)
推荐(0)
2021年2月22日
后端接收前端传的数据方式
摘要: 1. get方式获取: res = request.GET.get("name", " ") GET提交,请求的数据会附在URL之后(就是把数据放置在HTTP协议头中),以?分割URL和传输数据,多个参数用&连接 2. 以表单方式传数据 name = request.POST.get("name",
阅读全文
posted @ 2021-02-22 23:55 半日闲1
阅读(3521)
评论(0)
推荐(0)
2021年2月18日
Django中的BASE_DIR
摘要: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 1. os.path.abspath(file)返回的是.py文件的绝对路径,也就是settings.py这个文件路径 2. os.path.dirname(
阅读全文
posted @ 2021-02-18 22:03 半日闲1
阅读(1361)
评论(0)
推荐(0)
2021年2月2日
supervisor管理Django进程
摘要: 1. 安装:pip install supervisor 2. 重定向默认配置:echo_supervisord_conf > /etc/supervisord.conf 3. 修改配置文件目录,修改tmp目录 4. 启动服务:supervisord -c /etc/supervisord.conf
阅读全文
posted @ 2021-02-02 15:33 半日闲1
阅读(227)
评论(0)
推荐(0)
将一个文件内容写入到另外一个文件
摘要: 先将一个文件内容读取,再写入至另外一个文件 w+ 打开可读写文件,若文件存在则文件长度清为零,即该文件内容会消失。若文件不存在则建立该文件。 w 打开只写文件,若文件存在则文件长度清为0,即该文件内容会消失。若文件不存在则建立该文件。 with open("/data/test.txt", "r",
阅读全文
posted @ 2021-02-02 14:02 半日闲1
阅读(1145)
评论(0)
推荐(0)
上一页
1
···
6
7
8
9
10
11
12
13
14
···
19
下一页
公告