随笔分类 -  python

摘要:参考链接:https://cloud.tencent.com/developer/article/2042153 对一张输入图像完成Sobel滤波操作,C++实现的代码如下: Mat image = imread("D:/images/dannis1.png", IMREAD_GRAYSCALE); 阅读全文
posted @ 2025-05-05 14:13 kuaqi 阅读(30) 评论(0) 推荐(0)
摘要:Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named ‘encodings’ Current thread 0x0000037c (mo 阅读全文
posted @ 2024-01-05 17:15 kuaqi 阅读(56) 评论(0) 推荐(0)
摘要:import cv2 img = cv2.imdecode(np.fromfile("微信图片.jpg",dtype=np.uint8),-1) img = cv2.resize(img,dsize=(0, 0),fx=0.5,fy=0.5) cv2.imshow("Img",img) cv2.wa 阅读全文
posted @ 2023-07-29 21:14 kuaqi 阅读(280) 评论(0) 推荐(0)
摘要:1、初始化 1)两种初始化方法 # 初始化方法1 class BaseClass: def __init__(self, value): self.value = value class ChildClass(BaseClass): def __init__(self): BaseClass.__i 阅读全文
posted @ 2022-11-26 18:55 kuaqi 阅读(46) 评论(0) 推荐(0)
摘要:一、通识 1、在python中,类型属于对象,对象有不同类型的区分,变量是没有类型的! 1)变量a是没有类型的,它仅仅是一个对象的引用(一个指针),可以指向List类型对象,也可以是指向String类型对象 a = [1, 2, 3] a= 'Runoob' 二、字典 1、基本操作 # 声明空字典 阅读全文
posted @ 2022-08-20 20:20 kuaqi 阅读(91) 评论(0) 推荐(0)
摘要:1、多进程 1)在主线程中直接构造多个进程 #开进程的方法一: import time import random from multiprocessing import Process def piao(name): print('%s piaoing' %name) time.sleep(ran 阅读全文
posted @ 2022-08-16 20:26 kuaqi 阅读(22) 评论(0) 推荐(0)
摘要:1、判断元素,或多个元素是否在数组中 # 单个元素 'a' in ['a', 'b', 'c'] # true # 多个元素 {'a', 'b', 'b'}.issubset(['a', 'b', 'c']) #true {'a', 'b', 'b', ''}.issubset(['a', 'b', 阅读全文
posted @ 2022-08-01 19:08 kuaqi 阅读(109) 评论(0) 推荐(0)
摘要:pandas参考文件 一、DataFrame 1、构造 # 从字典构建 d = {'col1:[1,2], 'col2':[3,4]} d = {'col1:[1], 'col2':[3]} df = pd.DataFrame(data=d) df = pd.DataFrame(data=d, ty 阅读全文
posted @ 2022-07-30 23:32 kuaqi 阅读(90) 评论(0) 推荐(0)
摘要:1、判断路径是否存在,创建文件夹或多级文件夹 if not os.path.exists(path): os.mkdir(path) #os.makedir(path) 2、判断路径是文件还是文件夹 os.path.isfile(path) os.path.isdir(path) 3、列出路径下所有 阅读全文
posted @ 2022-07-30 22:52 kuaqi 阅读(39) 评论(0) 推荐(0)
摘要:报错:“Cannot open D:\Programs\Anaconda3\Scripts\pip-script.py” 网上很多说:easy_install pip,可是都没找到easy_install 解决方法:conda search pip,然后选择一个pip版本,再conda instal 阅读全文
posted @ 2022-05-12 22:26 kuaqi 阅读(100) 评论(0) 推荐(0)
摘要:除了类的私有属性__private_attrs、私有方法__private_method之外,还有类的专有方法,包括:__init__、__del__、__len__、...... 对于类的专有方法的说法之一是:在合适的时间,会自动调用其魔法方法,比如初始化时调用__init__,具体见链接。 在C 阅读全文
posted @ 2022-03-06 21:44 kuaqi 阅读(323) 评论(0) 推荐(0)
摘要:python2.7对应的opencv版本低于opencv3.2 阅读全文
posted @ 2021-12-12 17:15 kuaqi 阅读(109) 评论(0) 推荐(0)
摘要:1、字符串操作':\\' 替换为 '/' https://blog.csdn.net/qq_38463737/article/details/106965958 '/'.join(str_path.split('\\')) # 直接用str_path.displace('\\', '//')在win 阅读全文
posted @ 2021-07-16 18:26 kuaqi 阅读(31) 评论(0) 推荐(0)
摘要:1、排序sorted:将数组按某一值排序 def sort_by_target(mnist): reorder_train = np.array(sorted([(target, i) for i, target in enumerate(mnist.target[:60000])]))[:, 1] 阅读全文
posted @ 2021-07-15 23:27 kuaqi 阅读(203) 评论(0) 推荐(0)
摘要:1、加载本地图片到numpy格式 import matplotlib.pyplot as plt img = plt.imread("one_img.jpg") digit = img.reshape(1, -1) 2、保存numpy格式到本地 one_digit = X_train[1] one_ 阅读全文
posted @ 2021-07-15 16:08 kuaqi 阅读(161) 评论(0) 推荐(0)
摘要:1、基本函数,不止是内部函数 io.open(): some_file=io.open('somefile.txt','w+') .close(): .flush():刷新缓存,好像有时没用? .read(n):读取字符个数 .readline():读取一行字符:也可以指定字符个数 .readlin 阅读全文
posted @ 2020-06-27 17:10 kuaqi 阅读(162) 评论(0) 推荐(0)
摘要:os.getcwd() #用以获取当前的工作目录 os.chdir(path) #更改当前的工作目录 阅读全文
posted @ 2020-06-27 14:40 kuaqi 阅读(135) 评论(0) 推荐(0)
摘要:Anaconda 可以创建多个Evironment,针对不同的python版本;然后安装各个模块时,需要提前设置python版本,然后在其版本下安装对应的模块 1、创建新的Python环境:参考链接 1)命令 conda config --set auto_activate_base false / 阅读全文
posted @ 2019-11-25 10:36 kuaqi 阅读(1136) 评论(0) 推荐(0)