
python
雾霾的梦想
峰回路转,春暖花开
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
数串 python
if __name__=='__main__'n = raw_input()arr = raw_input().split()print ''.join(sorted(arr,lambda x,y:-cmp(x+y,y+x))思路:python提供了方便的接口,仅仅用了三行代码。控制台输入字符串,以空格分割,存入一个数组,1.冒泡排序。2.内部排原创 2018-01-03 15:06:33 · 267 阅读 · 0 评论 -
获取json文件中的URL
1.实例代码为实现获取json文件中的图像:# -*- coding:utf-8 -*-import requestsimport reimport osdef get_page_url(url, param): response = requests.get(url, params=param) response.encoding = 'utf-8' retu...原创 2018-04-09 14:25:55 · 3384 阅读 · 0 评论 -
opencv读入图像
import cv2from glob2 import globfor fn in glob('*.jpg'): #确认文件格式 img=cv2.imread(fn)horizontal_img=cv2.flip(img,1)splitName=fn.split(".") newName=splitName[0] cv2.imwrite(newName+'_flip.jpg',horiz...转载 2018-04-09 15:39:12 · 330 阅读 · 0 评论 -
滤镜、图像运算
1.平滑处理、灰度化、二值化等:import cv2.cv as cvimage=cv.LoadImage('img/lena.jpg', cv.CV_LOAD_IMAGE_COLOR) #Load the imagecv.ShowImage("Original", image)grey = cv.CreateImage((image.width ,image.height),8,1) #8dep...转载 2018-04-10 11:05:26 · 174 阅读 · 0 评论 -
图像降噪python
1.opencv步骤:1)blur滤波去噪音2)floodfill清除背景色3)转为灰度图4)开闭运算使图像光滑5)转为2值图2.代码#-*- coding:utf-8 -*-import cv2 import numpy as npimg = cv2.imread("F/test.jpg") #载入图像h, w = img.shape[:2] #获取图像的高和宽 cv2.ims...原创 2018-04-10 14:59:52 · 1916 阅读 · 0 评论 -
Cython速生成Python扩展模块
Cython语法融合C和python1.pip install Cython2.helloworld目录下创建helloworld.pyx内容:cdef extern from"stdio.h": extern int printf(const char *format, ...)def SayHello():printf("hello,world\n")3.同目录建Setup.py内容:f...原创 2018-04-10 17:11:46 · 524 阅读 · 0 评论 -
Fast-CNN demo测试失败(nms)
1.提示No module named gpu_nms模块,分析:soft-nms-master\lib\nms\gpu_nms.pyx文件没有编译成python解决:安装cython编译成gpu_nms.py2.提示os.environ['CUDAHOME']不存在分析:环境变量不存在解决:重新配置环境变量3.numpy打开numpy/math.h失败,文件、路径不存在分析:宏定义出错,路径确实...原创 2018-04-10 17:18:34 · 1195 阅读 · 3 评论 -
线程池提高执行速度
CPU 密集型任务和 IO 密集型任务分别选择多进程和多线程库来进一步提高执行速度——这也是解决死锁问题的良方。CPU 密集型用multiprocessingIO 密集型用multiprocessing.dummyio密集型实例代码:from multiprocessing.dummy import Poolpool = Pool()pool.map(dowm_pic, temp[0], img...原创 2018-04-16 15:45:30 · 1079 阅读 · 1 评论 -
常用排序算法
1.快速排序def quick_sort(lists, left, right): # 快速排序 if left >= right: return lists key = lists[left] low = left high = right while left < right: while left &...原创 2018-04-04 15:57:17 · 139 阅读 · 0 评论 -
直方图比较图像,相似度小于5时重名名
#-*- coding:utf-8 -*-import cv2import osfrom nt import chdirclass CompareImage(object): def __init__(self, image_1_path, image_2_path): self.minimum_commutative_image_diff = 0.25 ...原创 2018-04-04 16:00:15 · 261 阅读 · 0 评论 -
coco MAP测试
1.根据TXT结果,json文件生成。#!/usr/bin/env python# coding=utf-8# Copyright 2017 challenger.ai## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in complia...原创 2018-06-04 10:41:26 · 3086 阅读 · 0 评论 -
日志文件除重并生成新的文件
1、log文件格式:======================Thread T9 (GTest) created by T0 here: #0 0xb7237dcc in pthread_create (/usr/lib/i386-linux-gnu/libasan.so.2+0x2fdcc) #1 0xacaede0d (libGTestServer.so+0x2ce0...原创 2019-06-16 09:04:58 · 512 阅读 · 0 评论 -
io 常用图像处理函数
1.读coll = io.ImageCollection(str)#用for循环读出coll的各个元素就是图像2.保存io.imsave('d:/data/'+np.str(i)+'.jpg',img) #循环保存图片3.修改 from skimage import data_dir,io,colorcoll = io.ImageCollection('d:/pic/*.jpg')prin...转载 2018-04-09 14:23:38 · 1981 阅读 · 0 评论 -
error: Couldn't find a setup script
python 安装mock错误提醒:error: Couldn't find a setup script解决方案:把安装包里面的mock文件夹拷贝到Python的Lib文件夹下原创 2018-04-01 16:50:43 · 4648 阅读 · 0 评论 -
too many values to unpack
以下这句话python 错误提示:too many values to unpackfor root, files in os.walk(file_name):就是参数少了,改为:for root, dir1, files in os.walk(file_name):没问题了!!!!!...原创 2018-03-26 16:31:15 · 565 阅读 · 0 评论 -
读一个TXT文件中的指定字符串,另存到Excel里面
代码分析:1.新建Excel文件2.新建sheet3.读入TXT文件4.按行赋值给sheet(sheet1.write(temp, 0, company)的含义:将company这个变量的值赋给sheet的第temp行0列)5.save保存Excel6.释放读TXT文件的资源#!/usr/bin/python# -*- coding: UTF-8 -*-# 文件名:原创 2018-01-22 15:05:41 · 521 阅读 · 0 评论 -
selenium 屏幕快照
# -*- coding:utf-8 -*-from selenium import webdriverfrom bs4 import BeautifulSoupimport pdfcrowdimport reimport timeif __name__ == '__main__': # options = webdriver.ChromeOptions() # op原创 2018-01-05 11:17:42 · 888 阅读 · 0 评论 -
UnicodeDecodeError: 'ascii'
1.编码错误:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 1: ordinal not in range(128)2.解决:import sysreload(sys)sys.setdefaultencoding('utf8')3.提示:添加完以上三句话之后,需要把所以的字符都还原成没有原创 2018-01-31 15:38:41 · 2395 阅读 · 0 评论 -
python写一个TXT和写一张图片耗时
1.往一个txt中写入一条数据,耗时0.00005s2.往一个文件夹写一张图, 耗时0.21545s写一张图比写一条数据的时间多4309倍原创 2018-02-09 15:04:25 · 322 阅读 · 0 评论 -
网页截屏快照
1.帮朋友做的一个截取网页图片的from selenium import webdriverfrom bs4 import BeautifulSoupimport timeif __name__ == '__main__': # options = webdriver.ChromeOptions() # options.add_argument('use原创 2018-02-07 09:39:36 · 676 阅读 · 0 评论 -
selenium.common.exceptions.WebDriverException: Message: TypeError: can't acc
问题:selenium.common.exceptions.WebDriverException: Message: TypeError: can't access derad object分析:1.火狐版本可能存在问题方法:driver.switch_to.default_content()原创 2018-02-07 11:18:10 · 1894 阅读 · 0 评论 -
读取文件中的URL,下载到本地,删除原文件
python:2.7引入模块:os\requests直接上代码:#-*- coding:utf-8 -*-import osimport requests#打开文件夹def open_file(file_name, size=0): for root, dirs, files in os.walk(file_name): for file in files: ...原创 2018-02-27 10:49:45 · 473 阅读 · 0 评论 -
python常见错误提醒
别人写的,备忘!!!0操作成功完成。 1功能错误。 2系统找不到指定的文件。 3系统找不到指定的路径。 4系统无法打开文件。 5拒绝访问。 6句柄无效。 7存储控制块被损坏。 8存储空间不足,无法处理此命令。 9存储控制块地址无效。 10环境错误。 11试图加载格式错误的程序。 12访问码无效。 13数据无效。 14存储器不足,无法完成此操作。 15系统找不到指定的驱动器。 16无法删除目录。 1...转载 2018-02-27 10:53:32 · 1019 阅读 · 0 评论 -
TypeError: unbound method Find() must be called with Solution instance as fi
源码如上图所示bug提示:我的问题是类后面缺失括号,加上正常运行原创 2018-03-01 17:10:39 · 3091 阅读 · 0 评论 -
二维数组控制台输入,赋值,
# -*- coding:utf-8 -*-class Solution: # array 二维列表 def Find(self, target, array): result = False for arr in array: for a in arr: if target == a: ...原创 2018-03-01 18:01:54 · 1368 阅读 · 0 评论 -
python打包成exe
1.pypi下载pyinstaller(也可以用pip install -U pyinstaller---我在安装的时候报个bug,所以还是下载下来再安装)2.cmd输入命令:python setup.py install3.安装完成4.新建.py(此处做个测试)5.cmd输入命令:python pyinstaller.py -F E:\pyworkfile\QQSpeakSpider\Main\...原创 2018-03-06 17:14:35 · 186 阅读 · 0 评论 -
根据系统时间或者日志里面EXCEPTION时间找到符合标准的文件
#根据系统时间找日志文件def swich_file(str,day_c): # statinfo = os.stat(str) statinfo = os.path.getctime(str) timeStruct = time.localtime(statinfo) tm_year = time.localtime(statinfo).tm_year-tim...原创 2019-07-10 17:58:56 · 271 阅读 · 0 评论