![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 64
CVer儿
开源让世界更美好
展开
-
pip下载&离线安装whl
下载whl安装包(./dirs 是安装包目录)原创 2023-07-05 16:54:48 · 1119 阅读 · 0 评论 -
31Python字符串方法
废话少说,直接上干货。▍1、Slicingslicing切片,按照一定条件从列表或者元组中取出部分元素(比如特定范围、索引、分割值)s='hello's=s[:]print(s)#hellos='hello's=s[3:8]print(s)#hello▍2、strip()strip()方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列。s='hello'.strip()...原创 2022-03-10 10:24:03 · 108 阅读 · 0 评论 -
Python切片、迭代、列表生成式、生成器与迭代器
切片切片(slice)的功能类似于R语言中的取数或者访问数据对象元素,但R中对象都是向量、矩阵数据框,在Py里面我们切片的作用对象是list、tuple或者dict等数据对象类型。假设一个list如下:L=['Durant','Curry','Green','James','Erving']如果我们想取用前3个元素,可以通过list的索引来做,但一旦元素个数过多,通过索引访问的方法就行不通了。当然我们也可以通过写for循环来遍历对象的每个元素。但通常这些方法比起切片来都过于繁琐:...原创 2022-01-26 14:29:01 · 195 阅读 · 0 评论 -
python中的__call__函数
其实就是把实例化的类当作一个函数使用,并之后通过call传入函数参数:class person(): def __init__(self,age,male) : self.age=age self.male=male pass def __call__(self,x): print("........") print("x: ",self.age*x) pass def mon原创 2021-09-02 11:18:26 · 521 阅读 · 0 评论 -
python的一些使用记录
1.python删除del列表复合某条件的元素lists列表中含有txt,jpg,png文件,只要jpg文件for i in range(len(lists))[::-1]: if lists[i].endswith("txt"): del lists[i]for i in range(len(lists))[::-1]: if lists[i].endswith("png"): del lists[i] .原创 2020-07-29 16:29:15 · 121 阅读 · 0 评论 -
损失函数篇----numpy实现dice损失函数
dice损失函数:# import keras.backend as Kimport cv2import numpy as np import ossmooth = 1.def dice_coef(y_true, y_pred): y_true_f = y_true.flatten() y_pred_f = y_pred.flatten() intersec...原创 2019-12-04 16:12:33 · 2077 阅读 · 0 评论 -
Python中self变量,__init__()变量——笔记
先看几个链接吧:1.https://www.cnblogs.com/Wanggcong/p/5162279.html2.https://www.crifan.com/summary_the_meaning_of_self_and___init___in_python_and_why_need_them/# -*- coding:utf8 -*-import osimpo...原创 2019-10-25 18:09:07 · 930 阅读 · 0 评论 -
python 操作文件和目录两道题目
1.利用os模块编写一个能实现dir -l输出的程序。2.编写一个程序,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径。import timeimport osfilelist = [x for x in os.listdir('.') if os.path.isfile(x)]#找到当前目录的文件类型的文件。path = os.path.ab...转载 2019-10-15 14:20:01 · 295 阅读 · 0 评论 -
关于深度学习中的np.expand_dims与np.squeeze用法
搬运参考链接:https://www.jb51.net/article/135307.htm比如写CNN模型相关代码时,我们需要借助python图像库来读取图像并进行一系列的图像处理工作。我最常用的图像库当然是opencv,很强大很好用,但是opencv也有一些坑,不注意的话也会搞出大麻烦。近期我也在看一些别人写的代码,因为个人习惯不一样,他们在做深度学习时用于图片读取的图像库各不相同,从...原创 2019-09-09 11:33:23 · 2846 阅读 · 0 评论 -
【opencv$$numpy$$PIL的学习思考】
刚入门,感觉给予python对以上三者很容易混淆,留下学习笔记,欢迎更正。1. 现在使用OpenCV-Python绑定,numpy是必装的import cv2 import numpy as np img = cv2.imread("./cat.jpg") emptyImage = np.zeros(img.shape, np.uint8) #创建副本 emp...原创 2019-08-14 16:17:13 · 135 阅读 · 0 评论 -
python的类练习
https://www.jianshu.com/p/59c317eab09chttps://www.jianshu.com/p/e17a052f1fd9class Person(object): def __init__(self,name,age): self.name = name self.age = age def say(self): print...原创 2019-08-06 19:01:57 · 193 阅读 · 0 评论 -
【python的numpy应用】
1. numpy1:numpy:https://www.cnblogs.com/reaptomorrow-flydream/p/9173161.html2:python x[:] x[::] x[:::]用法,切片和索引 python [:-1] [::-1]的理解(容易混淆) 所以a[::-1]相当于 a[-1:-len(a)-1:-1],也就是从最后一个元素到第一个元素复制...原创 2019-08-05 17:56:29 · 1007 阅读 · 1 评论 -
【Python---批量遍历命名】
批量遍历命名:脚本一# -*- coding: utf-8 -*-import os path_name=r'C:\\Users\\Administrator\\Desktop\\0430'#path_name :表示你需要批量改的文件夹i=0for item in os.listdir(path_name):#进入到文件夹内,对每个文件进行循环遍历 os.re...原创 2019-06-19 16:06:23 · 1189 阅读 · 0 评论 -
【python小练习】
import oslist1 = [x for x in range(0,10,2)]list2=['1','4','g','6']for i in range(len(list1)): print(list1[i], end='\n ') for x in list2: print(x, end='\n ')result=os.getcwd()p...原创 2019-04-19 17:50:07 · 131 阅读 · 0 评论