初学随笔
油腻的胖子
这个作者很懒,什么都没留下…
展开
-
python singledispatch和singledispatchmethod
【代码】python singledispatch和singledispatchmethod。原创 2023-02-26 10:59:25 · 179 阅读 · 0 评论 -
itemgetter和partial
itemgetter 偏函数 partial原创 2023-02-15 12:53:37 · 41 阅读 · 0 评论 -
python 注解及提取
python 函数注解原创 2023-02-14 19:05:06 · 338 阅读 · 0 评论 -
python 元类和__new__创建单例类
理解元类和__new__原创 2023-02-12 17:43:05 · 49 阅读 · 0 评论 -
classmethod的多态性
classmethod动态创建对象,实现类的多态原创 2023-02-12 17:06:01 · 49 阅读 · 0 评论 -
python 带参数的装饰器
python 装饰器原创 2023-02-02 20:15:40 · 87 阅读 · 0 评论 -
python 不带参数的装饰器
python 装饰器原创 2023-02-02 20:09:06 · 59 阅读 · 0 评论 -
自定义Dict
Python 自定义Dict原创 2023-02-01 20:17:51 · 62 阅读 · 0 评论 -
流畅的python 切片
python 切片原创 2023-01-22 15:52:24 · 85 阅读 · 1 评论 -
流畅的python-扑克牌
# -*-coding:utf-8-*-import collectionsfrom random import choice, choicesCard = collections.namedtuple('Card', ['rank', 'suit']) # 创建只包含基础属性的类bear = Card("7", "555")print(choice([2, 4, 5, 6, 7])) # 从迭代器中随机取值print(choices([2, 4, 5, 6, 7], k=3)) # 从.原创 2022-05-11 16:38:57 · 189 阅读 · 0 评论 -
python 连接redis
# __*__coding=utf-8__*__import redisclass Redis: def __init__(self): host = "10.*.*.*" port = 6379 dbbase = 12 password = "pwd" conn_pool = redis.ConnectionPool(host=host, password=password, port=port, db=db.原创 2021-03-25 09:55:18 · 56 阅读 · 0 评论 -
flask项目配置
flask项目配置可以由Flask对象的app属性进行配置:app.config["ADMIN_NAME"] = "JIM"app.config.update("ADMIN_NAME"=JIM,"IS_OK"=True)value = app.config["IS_OK"]原创 2021-02-08 15:00:18 · 109 阅读 · 0 评论 -
一个简单的flask案例
from flask import Flaskapp = Flask(__name__)@app.route("/hello")@app.route("/") # 注册路由def hello(): """ 视图函数 :return: <h1>Hello,Flask!</h1> """ return "<h1>Hello,Flask!</h1>"# 动态url@app.route("/hi", d.原创 2021-02-08 14:20:21 · 180 阅读 · 0 评论 -
python pipenv管理虚拟环境
1. 安装pipenvpip install pipenv2.创建虚拟环境pipenv install # 在当前文件夹创建python虚拟环境3.激活虚拟环境pipenv shell4.退出虚拟环境:exit5.不激活虚拟环境前提下在当前虚拟环境运行命令:pipenv run python hello.py6.安装和管理依赖pipenv install packagename # 会自动维护pipfile和pipfile.lock ...原创 2021-02-08 10:14:06 · 75 阅读 · 0 评论 -
JAVA学习小结--注解
1.理解注解:给方法、类、变量等添加一个标签,对添加了标签的实体根据标签的内容进行一些操作。注解的本质是一个Annotation的接口/**Annotation接口源码*/public interface Annotation { boolean equals(Object obj); int hashCode(); Class<? extends Annotation> annotationType();}2.JDK提供的注解:@Override原创 2021-01-26 22:12:38 · 54 阅读 · 0 评论 -
pytest总结摘要
1. 安装方式:pip install -U pytest2.文件、类和方法的名称文件名:test_*.py格式或*_test.py格式类名:Test*格式函数名:test_*格式原创 2021-01-19 13:50:31 · 91 阅读 · 0 评论 -
python request.session 带cookie
1. 登录获取cookiedef get_cookie(self): payload = { "loginName": user, "password": password } self.post_login(payload) cookie = self.rest.session.cookies return cookie2.session的封装函数中带cookiedef __init__(self, endp.原创 2021-01-18 21:24:52 · 712 阅读 · 0 评论 -
request封装:pyrest
cclass PyREST(object): def __init__(self, endpoint, header={'Content-Type': 'application/json', 'Connection': 'close'}, cookie=None): self.session = requests.session() self.session.cookies = cookie self.session.headers.upda.原创 2021-01-17 17:20:54 · 207 阅读 · 1 评论