coding(C++、python)
HccqXd
这个作者很懒,什么都没留下…
展开
-
利用python获取文件名,并批量复制给另一个文件夹
#!/usr/python#-*- coding:utf-8 -*-import osimport globimport shutilfilenames=set()#保存要复制的文件名集合,就是下面val.txt中的文件名#val.txt保存的是没有路径,没有后缀的文件名,比如2345,而不是~/"PATH"/2345.jpgwith open('/home/llc/llc/yolov3_keras/keras-yolo3/VOCdevkit/VOC2020/ImageSets/Main/原创 2020-12-10 15:55:01 · 686 阅读 · 1 评论 -
利用python批量提取xml文件中的某个类别的数目
import osimport xml.dom.minidomtotal_count = 0AnnoPath = './ads/ads_xml'Annolist = os.listdir(AnnoPath)for annotation in Annolist: filename = os.path.join(AnnoPath,annotation) dom = xml.dom.minidom.parse(filename) # 打开XML文件 collection = d原创 2020-12-03 11:10:34 · 978 阅读 · 3 评论 -
png生成gif图片
转载:https://blog.csdn.net/qq_14997473/article/details/90234420转载 2019-11-28 10:22:19 · 576 阅读 · 0 评论 -
python使用rename批量修改某文件夹下的文件名
#_*_coding:utf-8_*_import ospath="C:/Users/pc/Desktop/mask" #你自己的文件夹for root,dirs,files in os.walk("C:/Users/pc/Desktop/mask",topdown=True): for file in files: file_src_path=os.p...原创 2019-11-28 10:22:37 · 650 阅读 · 0 评论 -
三种方式(os.walk、glob、os.listdir)得到文件目录下的每个文件的文件名
#_*_coding:utf-8_*_import osimport globprint("=========walk()========")#os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]): #top -- 是你所要遍历的目录的地址, 返回的是一个三元组(root,dirs,files)。...原创 2019-11-28 10:22:14 · 1274 阅读 · 0 评论 -
python文件的读写操作
#_*_coding:utf-8_*_#打开文件with open('./data/text/1.txt') as f: #print(f.read()) #一次性读取所有文件内容 for line in f.readlines(): #保险的读取文件方法 print(line.strip()) #strip代表去末尾‘\n’#写文件with open...原创 2019-11-28 10:22:02 · 154 阅读 · 0 评论 -
24位转换成8位
不多解释,上代码:from PIL import Image lena = Image.open("./data/1.jpg")lena_L = lena.convert("L") #L:8位像素,黑白lena_L.save("./data/1_L.png")原创 2019-11-28 10:21:56 · 697 阅读 · 0 评论 -
python调用openpyxl实现excel的相同索引的拷贝操作
参考:https://diwugebingren.github.io/posts/b31985f0/我们的目的是想让表2从表1中拷贝以某索引相同的数据。比如表1的数据如下:表2暂时无数据:我们的目标就是让表2中同姓名的学生的各科成绩和表1对应起来。实现代码:#_*_coding:utf-8_*_from openpyxl import load_workbo...原创 2019-11-28 10:22:30 · 710 阅读 · 0 评论