![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python 工具
文章平均质量分 70
烨然_
个人网站gaoye.xyz
展开
-
cv2.imread 读取buffer 或者 读取二进制文件
``import numpy as npimport cv2src = cv2.imread(‘1.jpg’, 1)print(src.shape)以二进制形式读取图片,并将图片恢复为numpy数组with open(‘1.jpg’, ‘rb’) as f:imageBin = f.read()img1 = np.frombuffer(imageBin, np.uint8)print("img1 shape ", img1.shape) # (83653,)img_cv = cv2.im原创 2020-06-02 16:05:44 · 6111 阅读 · 0 评论 -
python调用其他文件中的函数或者类
01 在同一个文件夹下,调用函数或者类A.py文件中def test(): print('this is test func')class A: def test(): print('this is a class named A, its func is test() ')B.py文件中# way 1from A import testfrom A i...原创 2020-02-29 15:36:58 · 1386 阅读 · 0 评论 -
python常用函数整理
1. 判断文件/文件夹是否存在import osif os.path.exists("test.txt"): pass2. 目录连接import osnew_path = os.path.join(root_path, 'test.txt')原创 2020-02-28 16:48:22 · 527 阅读 · 0 评论 -
Matplotlib 常用画图函数整理
import matplotlib.pyplot as pltimport numpy as npx = np.linspace(-1, 1, 50)y1 = 2 * x + 1y2 = x**2plt.figure(num = 5, figsize = (4, 4))plt.plot(x, y1)plt.plot(x, y2, color = 'red', linewidth ...原创 2019-02-15 20:27:03 · 519 阅读 · 0 评论 -
python 多进程和多线程
在计算大量数据时,可以使用多进程 多线程机制来加速计算import multiprocessingimport osdef run_proc(name): print('Child process {0} {1} Running '.format(name, os.getpid()))if __name__ == '__main__': print('Parent pr...原创 2019-02-22 21:06:31 · 123 阅读 · 0 评论 -
python数据处理常用函数
1 . pandasimport pandas as pd## 读取data = pd.read_csv(filename,header=None)data =data.valuesprint(data.shape) ##此时 data 可作为numpy 数组来使用## 保存## 将 list 转化为 numpy 格式data_numpy = np.array(data_l...原创 2019-02-13 15:57:10 · 701 阅读 · 0 评论