04 2022 档案

摘要:简单 案例模板 import asyncio async def domwlpad(url): print('开始下载') await asyncio.sleep(2) # 网络请求 print('下载完成') async def main(): urls = [ 'www.baidu1.com', 阅读全文
posted @ 2022-04-30 08:24 我在春天等伱 阅读(139) 评论(0) 推荐(0)
摘要:1. 线程池使用 注意 : ProcessPoolExecutor 进程池 不好用 同进程一样 from concurrent.futures import ThreadPoolExecutor,ProcessPoolExecutor def fn(name): for i in range(10) 阅读全文
posted @ 2022-04-28 13:16 我在春天等伱 阅读(65) 评论(0) 推荐(0)
摘要:1. 方法一: 多线程 # 多线程 需要组件from threading import Threaddef func(): for i in range(100): print('fun', i)if __name__ == '__main__': # 开始使用线程 # 1. 实例化一个进程, 安排 阅读全文
posted @ 2022-04-28 11:29 我在春天等伱 阅读(125) 评论(0) 推荐(0)
摘要:0. ip更换 import requests url = 'https://www.baidu.com' # 代理ip proxies = { 'https':'218.1.1.1:3308' } reps = requests.get(url, proxies=proxies) print(re 阅读全文
posted @ 2022-04-28 09:36 我在春天等伱 阅读(151) 评论(0) 推荐(0)
摘要:1. re 正则表达式 提取数据 用法: 实战 : 案例 : 2. xpath 提取数据 方法一 1. 引用 2. 用法 方法二 sel = parsel.Selector(resp) # 当前图片的数量 num = sel.xpath('//div[@id="pages"]/a/text()') 阅读全文
posted @ 2022-04-27 16:11 我在春天等伱 阅读(192) 评论(0) 推荐(0)
摘要:1. 显示当前git 所在位置 主线(master) git branch 2. 新建分支bug git branch bug 3. 切换到新建的分支 修复 bug 代码 git checkout bug 4. 修复完毕 合并分支 , 首先要切换到 主线(master) 里面 合并时出现 冲突 代码 阅读全文
posted @ 2022-04-21 11:43 我在春天等伱 阅读(37) 评论(0) 推荐(0)
摘要:1. 安装 2. 使用 , 进入当前目录 3. 配置邮箱与用户名 git config --global user.email "121340751@qq.com" git config --global user.name "流浪" git init 初始化 git clone url 克隆到本地 阅读全文
posted @ 2022-04-20 21:08 我在春天等伱 阅读(28) 评论(0) 推荐(0)
摘要:pip install -i https://pypi.douban.com/simple openpyxl上面是导入表格的插件 1. 静态文件 <div class="form-group"> <label for="exampleInputFile">上传文件</label> <input ty 阅读全文
posted @ 2022-04-17 19:49 我在春天等伱 阅读(68) 评论(0) 推荐(0)
摘要:1. 静态页面 {% extends 'layout.html' %} {% block content %} <div class="container"> <!-- Button trigger modal --> <button type="button" class="btn btn-suc 阅读全文
posted @ 2022-04-16 11:25 我在春天等伱 阅读(97) 评论(0) 推荐(0)
摘要:1. 静态页面 {% extends 'layout.html' %} {% block content %} <div class="container"> <!-- Button trigger modal --> <button type="button" class="btn btn-suc 阅读全文
posted @ 2022-04-15 16:13 我在春天等伱 阅读(273) 评论(0) 推荐(0)
摘要:1. 静态页面 <div class="panel panel-default"> <div class="panel-heading"> 小案例 ajax学习之路 - jq 绑定事件 - 表单提交 </div> <div class="panel-body"> <form method="post 阅读全文
posted @ 2022-04-15 10:39 我在春天等伱 阅读(197) 评论(0) 推荐(1)
摘要:from django.shortcuts import render, HttpResponse, redirect def task_list(request): return render(request, 'task.html') def task_ajax(request): print( 阅读全文
posted @ 2022-04-13 15:53 我在春天等伱 阅读(72) 评论(0) 推荐(0)
摘要:1. 设置cookie 值 request.session['info'] = {'id': admin_row.id, 'name': admin_row.username} 2. 获取cookie info_dict = request.session.get['info'] info_dict 阅读全文
posted @ 2022-04-12 16:32 我在春天等伱 阅读(415) 评论(0) 推荐(0)
摘要:1. 建立文件夹 创建文件 auth.py from django.utils.deprecation import MiddlewareMixin from django.shortcuts import redirect '''中间件''' class AuthMiddleware(Middle 阅读全文
posted @ 2022-04-12 16:17 我在春天等伱 阅读(129) 评论(0) 推荐(0)
摘要:account.py 页面 from django.shortcuts import render, redirect from django import forms from app import models from app.utils.encrypt import md5 from app 阅读全文
posted @ 2022-04-12 14:22 我在春天等伱 阅读(133) 评论(0) 推荐(0)
摘要:''' 编辑密码类''' class AdminAddModelForm(BootstrapModelForm): # 定义重复密码字段 confirm_pwd = forms.CharField( label='重复密码', # 加入插件 让重复密码变成密文 (render_value=True) 阅读全文
posted @ 2022-04-11 23:09 我在春天等伱 阅读(106) 评论(0) 推荐(0)
摘要:'''重置密码类'''class AdminChongModelForm(BootstrapModelForm): confirm_pwd = forms.CharField( label='重复密码', # 加入插件 让重复密码变成密文 (render_value=True) 让错误的密码不会置空 阅读全文
posted @ 2022-04-11 23:06 我在春天等伱 阅读(194) 评论(0) 推荐(0)
摘要:admin.py from django.shortcuts import render, HttpResponse, redirectfrom app import modelsfrom django.core.exceptions import ValidationErrorfrom app.u 阅读全文
posted @ 2022-04-10 16:45 我在春天等伱 阅读(154) 评论(0) 推荐(0)
摘要:bootsrap.py 文件 from django import forms class BootstrapModelForm(forms.ModelForm): # 重定义方法 添加input 样式 def __init__(self, *args, **kwargs): super().__i 阅读全文
posted @ 2022-04-10 16:24 我在春天等伱 阅读(176) 评论(0) 推荐(0)
摘要:项目 此项目是bootstrap-datetimepicker 项目 的一个分支,原项目不支持 Time 选择。其它部分也进行了改进、增强,例如load 过程增加了对 ISO-8601 日期格式的支持。文档是拷贝/粘贴字原项目的文档,并且加入了更多细节说明。 别犹豫了,下载下来试试吧 ! 下载 ZI 阅读全文
posted @ 2022-04-09 14:47 我在春天等伱 阅读(3583) 评论(0) 推荐(0)
摘要:样式显示效果 html 文件 {% extends 'layout.html' %}{% load static %}<!-- 引入样式 -->{% block css %} <link rel="stylesheet" href="{% static 'css/bootstrap-datetime 阅读全文
posted @ 2022-04-09 14:43 我在春天等伱 阅读(74) 评论(0) 推荐(0)
摘要:'''为靓号编辑 设立一个类''' class NumberEditModelForm(forms.ModelForm): # 限制修改字段 注意mobile 字段放的位置 # mobile = forms.CharField(disabled=True, label='号码') # 重新定义一次 阅读全文
posted @ 2022-04-09 12:45 我在春天等伱 阅读(169) 评论(0) 推荐(0)
摘要:添加数据 : # 方法2 钩子方法 clean_字段名(self) # 校验已经存在的手机号 禁止入库 def clean_mobile(self): # 获取用户传入的数据 text_mobile = self.cleaned_data['mobile'] # exists() 验证手机号是否存在 阅读全文
posted @ 2022-04-09 12:00 我在春天等伱 阅读(112) 评论(0) 推荐(0)
摘要:1. 分页的基础 views.py # 分页代码 page = int(request.GET.get('page', 1)) paeg_size = 10 start = (page - 1) * paeg_size end = page * paeg_size # 查询结果输出 number_l 阅读全文
posted @ 2022-04-07 08:43 我在春天等伱 阅读(781) 评论(0) 推荐(0)
摘要:多继承 按顺序 调用, 继承 A B 优先使用A 里面的方法 阅读全文
posted @ 2022-04-04 23:46 我在春天等伱 阅读(59) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2022-04-04 21:35 我在春天等伱 阅读(26) 评论(0) 推荐(0)
摘要:1. if 语句 2. 逻辑运算与 if 混合使用 阅读全文
posted @ 2022-04-04 21:24 我在春天等伱 阅读(29) 评论(0) 推荐(0)
摘要:2. 变量类型 案例 : 1. strip() 删除 字符串的空格 与 特殊字 \t\r\n 都会被清除 1. 阅读全文
posted @ 2022-04-04 18:15 我在春天等伱 阅读(34) 评论(0) 推荐(0)
摘要:Python生成随机验证码,需要使用PIL模块. 安装: pip3 install pillow 基本使用 1. 创建图片 from PIL import Image img = Image.new(mode='RGB', size=(120, 30), color=(255, 255, 255)) 阅读全文
posted @ 2022-04-04 13:53 我在春天等伱 阅读(221) 评论(0) 推荐(0)
摘要:views.py 代码 '''手机靓号列表''' def number_list(request): # 建立一个空字典 data_dict = {} #接受查询数据 search_data = request.GET.get('q', '') #搜索 if search_data: data_di 阅读全文
posted @ 2022-04-04 08:40 我在春天等伱 阅读(222) 评论(0) 推荐(0)
摘要:views.py '''增加靓号''' from django.core.validators import RegexValidator class NumberModelForm(forms.ModelForm): # 重新定义一次 手机号的格式问题 mobile = forms.CharFie 阅读全文
posted @ 2022-04-03 21:42 我在春天等伱 阅读(3555) 评论(0) 推荐(0)
摘要:1. html代码 <span style="color: #f90">{{ field.errors.0 }}</span> 2. viewa.py '''高级方法添加 待验证方法循环'''class UserModelForm(forms.ModelForm): # 进一步对数据校验 如: na 阅读全文
posted @ 2022-04-03 12:59 我在春天等伱 阅读(100) 评论(0) 推荐(0)
摘要:modelform 代码案例 : html 文件 {% for ziduan in form %} <div class="form-group"> <label for="exampleInputEmail1"> {{ ziduan.label }}</label> {{ ziduan }} </ 阅读全文
posted @ 2022-04-02 20:15 我在春天等伱 阅读(51) 评论(0) 推荐(0)
摘要:1. srtting.py 文件去掉代码 'DIRS': [] 2. bootstrap 的引入路径 {% load static %} 绝对路径 #样式路径 <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> <s 阅读全文
posted @ 2022-04-02 14:22 我在春天等伱 阅读(108) 评论(0) 推荐(0)
摘要:1. 首先创建数据 , 创建表 2. 文件model.py代码: from django.db import models'''部门表'''class BuMen(models.Model): title = models.CharField(verbose_name='部门名称', max_len 阅读全文
posted @ 2022-04-02 10:12 我在春天等伱 阅读(335) 评论(0) 推荐(0)
摘要:清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://p 阅读全文
posted @ 2022-04-01 20:27 我在春天等伱 阅读(75) 评论(0) 推荐(0)