随笔分类 -  python

摘要: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 阅读(23) 评论(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 阅读(187) 评论(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 阅读(43) 评论(0) 推荐(0) 编辑
摘要:一、通识 1、在python中,类型属于对象,对象有不同类型的区分,变量是没有类型的! 1)变量a是没有类型的,它仅仅是一个对象的引用(一个指针),可以指向List类型对象,也可以是指向String类型对象 a = [1, 2, 3] a= 'Runoob' 二、字典 1、基本操作 # 声明空字典 阅读全文
posted @ 2022-08-20 20:20 kuaqi 阅读(78) 评论(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 阅读(18) 评论(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 阅读(63) 评论(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 阅读(85) 评论(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 阅读(35) 评论(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 阅读(90) 评论(0) 推荐(0) 编辑
摘要:除了类的私有属性__private_attrs、私有方法__private_method之外,还有类的专有方法,包括:__init__、__del__、__len__、...... 对于类的专有方法的说法之一是:在合适的时间,会自动调用其魔法方法,比如初始化时调用__init__,具体见链接。 在C 阅读全文
posted @ 2022-03-06 21:44 kuaqi 阅读(312) 评论(0) 推荐(0) 编辑
摘要:python2.7对应的opencv版本低于opencv3.2 阅读全文
posted @ 2021-12-12 17:15 kuaqi 阅读(104) 评论(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 阅读(24) 评论(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 阅读(197) 评论(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 阅读(154) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示