Python
Etrue
居深圳,从事机器视觉行业,有多年图像算法编程、MFC程序、嵌入式程序开发经验
展开
-
TypeError: only integer scalar arrays can be converted to a scalar index
TensorFlow取数据批次的代码中有一句yield inputs[excerpt], inputsp[excerpt]编译后报错TypeError: only integer scalar arrays can be converted to a scalar index改成yield np.array(inputs)[excerpt], np.array(inputsp)[exc...原创 2019-12-09 15:46:40 · 236 阅读 · 0 评论 -
图片自动裁剪的python实现
import osfrom PIL import Imageinputpath = "D:\\Program Files\\TEST\\pictures\\013"outpath = "E:\\picOutput\\013"fileNameStr = "013_"path2 = os.listdir(inputpath)for dirs in path2: path3 ...原创 2019-11-20 17:14:30 · 1231 阅读 · 0 评论 -
numpy 输出的时候和保存时不使用科学计数法
显示:np.set_printoptions(suppress=True)np.set_printoptions(precision=3) #设精度为3输出:np.savetxt('data/submit.txt', res, fmt='%.03f') #保留3位小数#保存为矩阵形式:np.savetxt('D:/data/w1.txt', result3, fmt=['%d,'...原创 2019-11-14 14:30:55 · 3724 阅读 · 0 评论 -
python 自动补齐二进制数据
今天应同事要求写了一个把二进制数据前面补零,使数据全部对齐的脚本。原本的数据的一行比如: 101010补齐后为: 00101010具体实现方法如下:if os.path.isdir(path3): path4 = os.listdir(path3) for path5 in path4: if path5.find("ori")>=0 or ...原创 2019-11-07 17:35:29 · 3048 阅读 · 0 评论 -
List初始化
话不多说,上一段代码一目了然:list1 = [5.0]* 5list2 = list([1.0] for i in range(10))list3 = [[1.0] for i in range(10)]list4 = [[2.0] * 5]print(list1)print(list2)print(list3)print(list4)运行结果:[5.0, 5.0,...原创 2019-11-06 10:16:28 · 92 阅读 · 0 评论 -
python便捷获取当前路径
python 获取当前路径: “./”获取当前路径的上一层:“./”举个栗子:(lena.jpg放在当前路径的上一层)import tensorflow as tfimport cv2img = tf.image.convert_image_dtype(tf.image.decode_jpeg(tf.read_file('../lena.jpg'), channels=1...原创 2019-10-25 16:09:24 · 287 阅读 · 1 评论 -
Python 程序出现ImportError: cannot import name 'is_string_like' 解决办法
今天的一个project写了如下代码:from skimage import os,transform运行后报错: from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_labelImportError: cannot import name 'is_string_like'网上查了一下,...原创 2019-10-23 15:07:45 · 5209 阅读 · 2 评论 -
Python的字符串处理函数split & join的使用一例
python 中split 和join 的妙用原创 2015-06-24 11:02:16 · 379 阅读 · 0 评论