上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 19 下一页
摘要: 设置参数 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 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 例: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 阅读(48) 评论(0) 推荐(0) 编辑
摘要: datetime 模块中 常用 second 和 total_seconds() 来获取时间差 seconds 忽略天 只看时分秒 total_seconds() 真正的时间差 包含天 1. 模型创建时间字段 create_time = models.DateTimeField("创建时间", nu 阅读全文
posted @ 2021-03-02 20:12 半日闲1 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 视图函数 中间件类 class JsonMiddleware(MiddlewareMixin): def process_response(self, request, response): if isinstance(response, HttpResponse): return response 阅读全文
posted @ 2021-03-01 21:28 半日闲1 阅读(45) 评论(0) 推荐(0) 编辑
摘要: 1. get方式获取: res = request.GET.get("name", " ") GET提交,请求的数据会附在URL之后(就是把数据放置在HTTP协议头中),以?分割URL和传输数据,多个参数用&连接 2. 以表单方式传数据 name = request.POST.get("name", 阅读全文
posted @ 2021-02-22 23:55 半日闲1 阅读(3371) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(1236) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 先将一个文件内容读取,再写入至另外一个文件 w+ 打开可读写文件,若文件存在则文件长度清为零,即该文件内容会消失。若文件不存在则建立该文件。 w 打开只写文件,若文件存在则文件长度清为0,即该文件内容会消失。若文件不存在则建立该文件。 with open("/data/test.txt", "r", 阅读全文
posted @ 2021-02-02 14:02 半日闲1 阅读(918) 评论(0) 推荐(0) 编辑
摘要: 将ip端口写进hosts文件末行,使用追加 w+:先清空所有文件内容,然后写入,然后你才可以读取你写入的内容 r+:不清空内容,可以同时读和写入内容。 写入文件的最开始 a+:追加写,所有写入的内容都在文件的最后 host = "192.168.95.127" port = 3306 with op 阅读全文
posted @ 2021-02-01 15:25 半日闲1 阅读(202) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 19 下一页