python
2c不高兴
一枚前端开发搬运工,面向api开发,百度谷歌搜索一键复制粘贴攻城狮
展开
-
NameError: name ‘_mysql‘ is not defined
NameError: name ‘_mysql‘ is not defined原创 2023-02-02 11:28:45 · 8340 阅读 · 0 评论 -
python 爬虫(头像)
import reimport osimport requestsglobal ii = 0def get_one_page(url): response = requests.get(url) response.encoding = 'utf-8' html = response.text return htmldef get_urls(html): pattern = re.compile('href="(/touxiang/qinglv/.原创 2022-04-20 16:12:23 · 1518 阅读 · 0 评论 -
python 爬虫(表情包)
引入模块import requests //用于请求网页import re //正则表达式,用于解析筛选网页中的信息要爬的网址headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0' }response = requests.get('https://qq.yh31.com/zjbq/',headers=headers) .原创 2022-04-20 15:32:26 · 1592 阅读 · 0 评论 -
Django 邮件发送
settings# 邮箱配置EMAIL_HOST = 'smtp.qq.com'EMAIL_PORT = 25 #发件箱的smtp服务器端口EMAIL_HOST_USER = 'xxx@qq.com' # 你的 QQ 账号EMAIL_HOST_PASSWORD = '秘钥'EMAIL_USE_TLS = True # 这里必须是 True,否则发送不成功EMAIL_FROM = 'xxx@qq.com' # 你的 QQ 账号view.py email_title = '后台管理系统'原创 2022-03-23 14:45:50 · 2149 阅读 · 0 评论 -
python 钉钉机器人推送消息
timestamp = str(round(time.time() * 1000)) secret = 'this is secret' secret_enc = secret.encode('utf-8') string_to_sign = '{}\n{}'.format(timestamp, secret) string_to_sign_enc = string_to_sign.encode('utf-8') hmac_code = hmac.new(secret原创 2022-03-23 14:42:19 · 2840 阅读 · 0 评论 -
Django JWT token 登录注册
setting.py INSTALLED_APPS = [ ... 'rest_framework', 'rest_framework.authtoken', 'corsheaders', # 添加 django-cors-headers 使其可以进行 cors 跨域 'app01',...]MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.s原创 2022-02-24 11:28:29 · 1740 阅读 · 0 评论 -
Django 分页 (PageNumberPagination)
传参 按照参数分页 不传返回全部核心代码:from rest_framework.pagination import PageNumberPagination# 分页(局部):自定义分页器 局部class PageNum(PageNumberPagination): # 查询字符串中代表每页返回数据数量的参数名, 默认值: None page_size_query_param = 'page_size' # 查询字符串中代表页码的参数名, 有默认值: page ..原创 2022-02-24 11:20:19 · 1988 阅读 · 0 评论 -
python Django增删改查 快速体验
先创建个app子级python python startapp app01然后创建数据模型app01下的modules.py文件from django.db import models# Create your models here.class UserInfo(models.Model): name=models.CharField(max_length=32) password=models.CharField(max_length=12) age=m...原创 2022-02-15 15:33:17 · 2015 阅读 · 0 评论