随笔分类 - python
摘要:img = cv2.imread(test_data_dir)img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
阅读全文
摘要:dump: 将数据写入json文件中 1 with open("../config/record.json","w") as f: 2 json.dump(new_dict,f) 3 print("加载入文件完成...") load:把文件打开,并把字符串变换为数据类型 1 with open(".
阅读全文
摘要:img_list = 'neg.lst' geter = GetImageSize(img_list) geter.threaded(thread_num=32) geter.save(img_list[:-4]+'_withsize.lst') s[:-4]是什么? 这是字符串切片的意思。与列表和
阅读全文
摘要:import syspythonpath = sys.executableprint(pythonpath)
阅读全文
摘要:python很蠢,路径问题一直让人头疼。 import sys print(sys.path) # 查看当前路径 from os import pathd = path.dirname(__file__) # 获取当前路径parent_path = os.path.dirname(d) # 获取上一
阅读全文
摘要:pip show xxxx pip list https://blog.csdn.net/swansonge/article/details/115957148
阅读全文
摘要:Python replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。 语法 replace()方法语法: str.replace(old, new[, max]) 参数 old -- 将被替换的子字符串。 new -
阅读全文
摘要:1.反斜杠. \ a = 1 b = 2 c = a +\ b print(c) longstring = 'this is a long long long long long long long \ string' print(longstring) 2.三引号 longstring1 = ''
阅读全文
摘要:数字格式化 https://www.runoob.com/python/att-string-format.html 下表展示了 str.format() 格式化数字的多种方法: >>> print("{:.2f}".format(3.1415926)) 3.14 '{:b}'.format(11)
阅读全文
摘要:Python中分为3种除法: 1./ 2.% 3.//地板除,-5//-2=2,-1//-5=0,2//3=0,3//2=1 https://blog.csdn.net/TeFuirnever/article/details/89046679
阅读全文
摘要:python2.x range() 函数可创建一个整数列表,一般用在 for 循环中。 注意:Python3 range() 返回的是一个可迭代对象(类型是对象),而不是列表类型, 所以打印的时候不会打印列表 加上list()可以返回一个列表 >>> print([range(10)]) [rang
阅读全文
摘要:1.np.zeros()该函数返回一个ndarray。输出数组是具有指定形状, dtype, order并包含零的数组。 import numpy as np a=np.zeros(6,) a 输出 array([0., 0., 0., 0., 0., 0.]) 2. 函数功能:Return ran
阅读全文
摘要:split(' ')返回以空格分割后的字符串列表 strip()去除首尾的空格 eg. x=" frames/video_1 num_frames label_1 " tmp = x.strip().split(' ') print(tmp) # result:['frames/video_1',
阅读全文
摘要:描述 extend() 函数用于在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)。 语法 extend()方法语法: list.extend(seq) 参数 seq -- 元素列表。 返回值 该方法没有返回值,但会在已存在的列表中添加新的列表内容。 实例 以下实例展示了 exten
阅读全文
摘要:参考链接:https://www.shangmayuan.com/a/439e322475624f9981b35cd2.html PIL(Python Image Library)是python的第三方图像处理库,可是因为其强大的功能与众多的使用人数,几乎已经被认为是python官方图像处理库了。
阅读全文
摘要:图像预处理转化为Tensor后的unsqueeze(0)有什么意义? image = transform(image).unsqueeze(0) 这个unsqueeze(0),感觉就仅仅在在最外层增加了一个维度,有什么意义吗? unsqueeze()这个函数主要是对数据维度进行扩充。给指定位置加上维
阅读全文
摘要:dict() 函数用于创建一个字典。 https://www.runoob.com/python/python-func-dict.html
阅读全文
摘要:https://zhuanlan.zhihu.com/p/36173202
阅读全文
摘要:1、通配符导入(不提倡)。 from os import * 2、单行导入单个模块 import json 3、单行导入多个模块 import os, sys, time 4、导入指定的模块属性 from os import path, fork, mkdir https://blog.csdn.n
阅读全文
摘要:https://docs.python.org/zh-cn/3/library/argparse.html#module-argparse 文档非常详细 import argparse parser = argparse.ArgumentParser() parser.add_argument("e
阅读全文