![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python 知识点
sinat_15355869
这个作者很懒,什么都没留下…
展开
-
sanic & flask & fastapi 对比
代码:from flask import Flaskapp = Flask(__name__)@app.route("/")def hello_world(): return "hello, flask!"if __name__ == "__main__": app.run(host="127.0.0.1", port=8080)# -----from sanic import Sanicfrom sanic.response import jsonap原创 2022-04-18 00:13:14 · 4076 阅读 · 0 评论 -
咖喱鸡 & 程序员 & 代码
如图所示:视频如下:咖喱鸡饭 - 这样做简直太香啦_哔哩哔哩_bilibili原创 2022-03-02 18:34:02 · 122 阅读 · 0 评论 -
np.sum() 用法 & np.log() 用法 & np.expand_dims() 用法
import numpy as np# axis = 0表示对最外层[]里的最大单位块做块与块之间的运算,同时移除最外层[]:a = np.array([1, 2, 3])print(a.sum(axis=0))"""6"""a = np.array([[1, 2], [3, 4]])print(a.sum(axis=0))"""[4 6]"""a = np.array([[[1, 2], [3, 4]], [[11, 12], [13, 14]]])print(a)p.原创 2020-06-06 14:21:20 · 777 阅读 · 0 评论 -
python 闭包
https://www.jianshu.com/p/3502bdf5485edef adder(x): def wrapper(y): return x + y return wrapperadder5 = adder(5)print(adder5(10))print(adder5.__closure__)print(adder5.__closure__[0].cell_contents)15(<cell at 0x7f0f554a4d50转载 2020-06-05 20:58:50 · 125 阅读 · 0 评论 -
【转】深入理解python中闭包,闭包的实质
谈谈自己的理解:python中闭包,闭包的实质转自:稀里糊涂林老冷def outer(a): b = 10 def inner(): print(a + b) return innerif __name__ == "__main__": demo = outer(5) demo() demo = outer(7...转载 2020-04-23 21:23:42 · 166 阅读 · 0 评论 -
基本用法 *args和**kwargs
# https://blog.csdn.net/seasermy/article/details/102696096 python中运算符*和**的作用-参数传递def pack(a, *b): print(type(a), a) print(type(b), b)pack(1, 2, 3, 4, 5)def pack2(a, **b): print(ty...原创 2020-04-02 18:00:20 · 129 阅读 · 0 评论 -
[转]argparse --- 命令行选项、参数和子命令解析器
argparse --- 命令行选项、参数和子命令解析器Python-argparse-命令行与参数解析原创 2020-04-01 18:31:37 · 185 阅读 · 0 评论 -
python 缓存 lru_cache
感受一下import timefrom functools import lru_cache@lru_cache(maxsize=None)def fib(n): if n <2: return n return fib(n-1) + fib(n-2)s = time.time()print(fib(30))e = time.time()...原创 2020-03-13 17:18:01 · 1153 阅读 · 0 评论 -
progressbar python
看起来还行原创 2019-12-29 13:14:50 · 90 阅读 · 0 评论 -
【转】github clone 慢
亲测有效 转自链接,https://www.cnblogs.com/rxbook/p/11869835.html感谢浮.尘的分享 (侵删)1、查找域名对应的ip地址,并修改hosts文件linuxidc@linuxidc:~/linuxidc.com$nslookup github.global.ssl.fastly.NetServer: 127.0.0.53Ad...转载 2019-12-04 08:46:50 · 102 阅读 · 0 评论 -
Argparse 教程
【转自官网】基本用法熟悉一波Argparse 教程:https://docs.python.org/zh-cn/3/howto/argparse.htmlhttps://docs.python.org/zh-cn/3/library/argparse.html?highlight=argparse#module-argparse注意下 action 与 default...原创 2019-11-09 18:51:50 · 236 阅读 · 0 评论 -
scrapy crawler - 爬虫小记
最近熟悉了一波爬虫,挺有用的,推荐入门资料如下:【视频资料】:Python Scrapy Tutorial - YouTube 2018年最新Python3.6网络爬虫实战 廖xf商业爬虫(太多了,只能看小部分,不过确实很细) 当然如果不想写代码也是ok的,搜一搜八爪鱼,后羿采集器等类似app都挺方便好用的,可满足日常简单需求。【书籍资料】:还是推荐大神 崔庆才 的书【学习...原创 2019-09-17 00:53:48 · 954 阅读 · 0 评论 -
@staticmethod 与 @classmethod
一图胜千言:相同点:classmethod 和 staticmethod 都可以直接通过类调用类内部的 属性, 方法不同点:classmethod 可以再类中的某个方法中,调用类的其他方法,而staticmethod不行,只能A.foo1 .... 这种...原创 2019-08-27 14:14:37 · 79 阅读 · 0 评论 -
Subclass not inheriting parent class
【转】Subclass not inheriting parent class定义父类中的init,很多参数当子类继承父类时,如果子类不想重写父类中的init,可以把父类中的init参数=None (存在默认也行看情况),这样就ok了...原创 2019-07-22 16:05:43 · 131 阅读 · 0 评论 -
【转】yield的用法
https://blog.csdn.net/mieleizhi0522/article/details/82142856 作者:冯爽朗转载 2019-07-31 12:02:42 · 150 阅读 · 0 评论 -
Mac + opencv + python3.6 + pycharm 安装
解决2个问题:如何在Mac安装opencv,如何在pycharm中使用opencv【1】 在window安装opencv还是挺简单的,但是Mac上,还挺费事,废话不多说:网上有很多mac安装opencv教程, 我这里只推荐最新2018.4.8 YouTube视频,我认为这是最简单的安装方法(找了挺久的)【转】How to Install OpenCV on Mac OS with PYTHON (...原创 2018-05-05 18:11:59 · 1347 阅读 · 1 评论 -
python 中[list] append, insert, pop -- [dict] pop -- [set] add, remove, pop
【转】:Python可迭代对象中的添加和删除 对于List:classmates = ['Michael', 'Bob', 'Tracy']classmates.append('Adam') //添加在末尾,没有add()方法classmates.insert(1, 'Jack') //在指定位置添加classmates.pop(1) //在知道位置...转载 2018-09-03 10:58:53 · 403 阅读 · 0 评论 -
find_loop_cycle
def find_cycle(G, source=None, orientation=None): """Returns a cycle found via depth-first traversal. The cycle is a list of edges indicating the cyclic path. Orientation of directed edg...原创 2018-09-27 17:19:50 · 274 阅读 · 0 评论 -
【转】python中使用zip函数出现
【转】https://blog.csdn.net/weixin_37226516/article/details/60881763 在Python中使用zip函数,出现<zip object at 0x02A9E418>错误的原因是,你是用的是python2点多的版本,python3.0对python做了改动zip方法在Python 2 和Python 3中的不同 为何有...转载 2018-09-28 14:51:31 · 372 阅读 · 0 评论 -
python 赋值,浅拷贝,深拷贝
感谢前辈:学习连接来自:图解Python深拷贝和浅拷贝总结:本文介绍了对象的赋值和拷贝,以及它们之间的差异:Python中对象的赋值都是进行对象引用(内存地址)传递 使用copy.copy(),可以进行对象的浅拷贝,它复制了对象,但对于对象中的元素,依然使用原始的引用. 如果需要复制一个容器对象,以及它里面的所有元素(包含元素的子元素),可以使用copy.deepcopy()进...原创 2019-03-30 14:45:14 · 201 阅读 · 0 评论 -
python 动态绑定属性方法
import types# 定义类class Person(object): num = 0 def __init__(self, name, age=None): self.name = name self.age = age def eat(self): print('eat food')# 定义实例...原创 2019-03-28 19:41:25 · 434 阅读 · 0 评论 -
装饰器-python
【转载】:理解 Python 装饰器看这一篇就够了【转载】:简单聊聊Python中的wraps修饰器1)# 1) 【简单装饰器】use_logging 就是一个装饰器,它一个普通的函数,它把执行真正业务逻辑的函数 func 包裹在其中,看起来像 foo 被 use_logging 装饰了一样def use_logging(func): def wrapper():...转载 2019-04-22 16:01:39 · 267 阅读 · 0 评论 -
【转载】一个小白对staticmethod与classmethod区别的理解,绝对简单易懂
一个小白对staticmethod与classmethod区别的理解,绝对简单易懂转载学习一波~转载 2019-05-09 16:31:31 · 115 阅读 · 0 评论 -
python setdefault
b = [1, 2, 3, 2]new = {}for i, elt in enumerate(b): cc = new.setdefault(elt, []) print('\n') print('cc = ',cc) print('new = ', new) cc.append(i) print('cc =', cc) print...原创 2019-06-15 14:18:09 · 651 阅读 · 0 评论 -
【转】利用栈实现四则运算表达式求值,附Python代码
【转】https://blog.csdn.net/xyh1re/article/details/81634236转载 2019-06-04 16:12:20 · 745 阅读 · 0 评论 -
Map, Filter and Reduce
http://book.pythontips.com/en/latest/map_filter.html记录一波:特别是 列表中多个 True 中含有False中,1) 可以用all,any来做 --> 判断list是否都为True2) 也可以用reduce 来做reduce( (lambda x, y: x&y) ,[True, False, F...原创 2019-06-17 11:18:51 · 114 阅读 · 0 评论 -
【转】python有趣的解包用法
python有趣的解包用法 作者:python编程转载 2019-07-30 14:43:43 · 139 阅读 · 0 评论 -
转载:混淆矩阵(Confusion Matrix)
转载至:http://blog.csdn.net/joeland209/article/details/71078935混淆矩阵是除了ROC曲线和AUC之外的另一个判断分类好坏程度的方法。以下有几个概念需要先说明:TP(True Positive): 真实为0,预测也为0FN(False Negative): 真实为0,预测为1FP(False Positive): 真实为1,预测为0TN(Tru...转载 2018-03-20 13:47:40 · 530 阅读 · 0 评论