Python
文章平均质量分 53
fengjiexyb
这个作者很懒,什么都没留下…
展开
-
从环境云网站爬取数据
1、环境云网站:http://www.envicloud.cn/网站中包含全国各地关于环境方面的数据,我们这次只读取了广东省24小时天气历史数据。2、关于接口参考环境云帮助页面3、代码使用python语言实现4、爬取需要key,免费申请5、爬取后的数据保存在oracle中,所以需要cx_Oracle插件。安装方式在https://oracle.github.io/pytho原创 2017-08-19 17:52:04 · 3070 阅读 · 3 评论 -
Python格式化字符串
在Python中可以使用string模块中的字符串模板(Template)对象进行字符串的格式化>>> from string import Template>>> s = Template('There are ${howmany} ${lang} Quotation Symbols')>>>>>> print s.substitute(lang='Python', howm转载 2017-09-07 16:43:20 · 195 阅读 · 0 评论 -
Python默认编码错误SyntaxError: Non-ASCII character '\xe5'之解决方法
解决方法:python的默认编码文件是用的ASCII码,你将文件存成了UTF-8!!!(文件中存在中文或者其他语言,就会出现此问题!)解决办法很简单!!!在文件开头加入:# -*- coding: UTF-8 -*- 或者 #coding=utf-8(注:此语句一定要添加在源代码的第一行)原文地址:http://blog.csdn.net/g转载 2017-08-21 20:54:19 · 291 阅读 · 0 评论 -
python 的日志logging模块学习
原文地址:http://blog.csdn.net/yatere/article/details/66554451.简单的将日志打印到屏幕 import logginglogging.debug('This is debug message')logging.info('This is info message')logging.warn转载 2017-09-08 15:48:33 · 212 阅读 · 0 评论 -
python汉字字符串插入数据库的乱码问题
在python中字符串的编码是gbk(真的吗?),但是很多数据库中的编码是uft-8格式。所以在插入数据库中经常会产生乱码,或者插入产生异常。在单步调试的时候有时候也会看到乱码现象。在图中我是使用了一个list存储从数据库读出来的汉字,不知道为什么也是乱码,查看感觉像是gbk编码。但是这时候又不能直接转成utf-8,要先用gbk编码,再用utf-8解码才原创 2017-08-31 17:04:13 · 1326 阅读 · 0 评论 -
使用libsvm来训练mnist数据集
在这篇bolg 中我安装可libsvm,现在开始实现用libsvm来做手写数字识别minst文件可以在官网下载。下载后参考官网和这个网站来弄清楚文件的结构。我就不细说了。''' @author:fengjiexyb @time:2017-09-09''' # -*- coding:utf-8 -*-import loggingimport matplotlib.pyplo原创 2017-09-09 20:26:26 · 1258 阅读 · 0 评论 -
Python 下载百度图片搜索结果
#!/usr/bin/env python# -*- coding: utf-8 -*-# @Author: loveNightimport jsonimport itertoolsimport urllibimport requestsimport osimport reimport sysstr_table = { '_z2C$q': ':', '_z转载 2017-09-19 15:30:24 · 750 阅读 · 0 评论 -
使用libsvm来训练液晶数字识别
# -*- coding:utf-8 -*-'''@finish time:20170915@author;fengjiexybthis is a file that train and test LCD digitthe dataset is minethe result is 95.05%'''import loggingimport matplotlib.pyplot as原创 2017-09-19 16:00:48 · 1272 阅读 · 6 评论 -
图像二值化、提取边缘
# -*- coding:utf-8 -*-'''@finish time:20170914@author;fengjiexybthis code is used for my lcd digit dataset gray and binarization'''import picklefrom svmutil import *from PCV.tools import imto原创 2017-09-19 16:07:39 · 7534 阅读 · 0 评论 -
使用svm进行蚊子识别
# -*- coding:utf-8 -*-'''@finish time:20170915@author;fengjiexybthis is a file that train and test LCD digitthe dataset is minethe result is 95.05%'''import loggingimport matplotlib.pyplot as原创 2017-09-19 16:08:42 · 1359 阅读 · 2 评论 -
详解pycharm新建文件时头部的模板
如何对pycharm头部模板进行个人的全新定制呢1Creating a file template from scratch2Creating a file template from an existing one3Creating a file template from a file4Creating and referencing include templates转载 2017-10-09 10:30:57 · 680 阅读 · 0 评论 -
python字符串前面加u,r,b的含义
u/U:表示unicode字符串 不是仅仅是针对中文, 可以针对任何的字符串,代表是对字符串进行unicode编码。 一般英文字符在使用各种编码下, 基本都可以正常解析, 所以一般不带u;但是中文, 必须表明所需编码, 否则一旦编码转换就会出现乱码。 建议所有编码方式采用utf8r/R:非转义的原始字符串 与普通字符相比,其他相对特殊的字符,其中可能包含转义字符,即那些,反转载 2017-09-30 14:31:47 · 558 阅读 · 0 评论 -
Python序列化
在此处输入标题标签(空格分隔): 未分类Python序列化持久化所谓持久化就是把内存中的数据保存在外存(包括数据库)中,达到长期保存的目的。序列化序列化就是讲数据转换为可以通过网络传输或者可以存储到本地磁盘的数据格式(例如xml、json、字符串等) Python常用的序列化模块有json、pickle、shelve。比较 模块名称 描述 提供的api json 用于实现P原创 2017-09-30 17:27:00 · 962 阅读 · 0 评论 -
Python的zip函数
原文地址:http://www.cnblogs.com/frydsh/archive/2012/07/10/2585370.htmlzip函数接受任意多个(包括0个和1个)序列作为参数,返回一个tuple列表。具体意思不好用文字来表述,直接看示例:1.示例1:x = [1, 2, 3]y = [4, 5, 6]z = [7, 8, 9]xyz = zip(x, y,转载 2017-09-07 16:18:57 · 188 阅读 · 0 评论 -
Python切片问题
1、Python 语言使用range()函数来生成一个整数列表。函数有三种类型1) range(int)这个函数生成一个0~int-1的列表,步长为12)range(intStart,intEnd)这个函数生成一个intStart~intEnd-1的列表,步长为13)range(intStart,intEnd,intStep)这个函数生成一个intStart~intEnd-1的列表,步原创 2017-09-07 16:00:04 · 390 阅读 · 0 评论 -
使用非官方软件在windows上安装libsvm
官方的libsvm下载后程序仍然显示找不到模块。去万能宝库(http://www.lfd.uci.edu/~gohlke/pythonlibs/)上,根据自己的python和操作系统下载对应版本的.whl文件我下载的是libsvm-3.22-cp27-cp27m-win_amd64.whlcp27表示Python版本是2.7win_amd64表示64位windows系统打开原创 2017-09-05 18:48:08 · 453 阅读 · 0 评论 -
python图像预处理
# -*- coding:utf-8 -*- '''Created on 2017年8月4日@author: fengj'''import numpy as npfrom PIL import Image, ImageFilterimport mathimageWidth=151#图片宽度imageHeight=112#图片高度#每个点用他旁边的8个点及自己综合平均d原创 2017-08-19 20:49:15 · 6442 阅读 · 0 评论 -
使用opencv2查看图片彩色直方图
# -*- coding:utf-8 -*- '''Created on 2017年8月10日@author: fengj'''import cv2import numpy as npfrom matplotlib import pyplot as pltimg = cv2.imread("C:\\Users\\fengj\\Desktop\\1.png")'''彩色直方图'原创 2017-08-19 20:53:30 · 485 阅读 · 0 评论 -
使用opencv2变换图片大小
# -*- coding:utf-8 -*- '''Created on 2017年8月10日@author: fengj'''import cv2import numpy as npfrom matplotlib import pyplot as pltimg = cv2.imread("C:\\Users\\fengjiexyb\\Desktop\\0.png")heig原创 2017-08-19 20:55:33 · 481 阅读 · 0 评论 -
python寻找list中最大值、最小值并返回其所在位置
c = [-10,-5,0,5,3,10,15,-20,25]print c.index(min(c)) # 返回最小值print c.index(max(c)) # 返回最大值原文地址:http://blog.sciencenet.cn/blog-350278-629028.html转载 2017-08-20 23:16:18 · 176803 阅读 · 10 评论 -
pillow安装
python处理图像需要使用pil库。但是这个库并不好用,而且更新不及时。所以一般使用pillow。在http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil,搜索pillow,下载最新版Pillow‑4.2.1‑cp36‑cp36m‑win_amd64.whl在命令行执行:pip install Pillow‑4.2.1‑cp36‑cp36原创 2017-08-20 23:22:12 · 839 阅读 · 0 评论 -
Python怎样得到资源文件的绝对路径
原文地址:http://blog.csdn.net/shendl/article/details/7591995import osimport sysif __name__ == '__main__': ABSPATH=os.path.abspath(sys.argv[0]) print ABSPATH转载 2017-08-21 20:53:28 · 595 阅读 · 0 评论 -
python下双星号的意义
a=b**2表示a=b^2但是还有其他用法。参考 http://chen.junchang.blog.163.com/blog/static/63445192013024115430149/原创 2017-08-21 21:06:12 · 703 阅读 · 0 评论 -
python中reshape的负参数
numpy reshape(-1,1)如果参数中存在-1,表示该参数由其他参数来决定,例如原来的矩阵是28*28=784,那么执行 reshape(-1,1),表示第二个参数为1,那么由此推出第一个参数为784。原创 2017-08-21 21:09:37 · 2997 阅读 · 0 评论 -
多参数的for循环问题
在python中,如果for循环的参数是多个数组,那么每个数组都会一起循环,例如biases=[1,2.3]weights=[1,2.3]for b, w in zip(biases, weights):那么b,w的取值为 (1,1)(2,2)(3,3),而不是分别循环,取9组值。原创 2017-08-21 21:12:51 · 3749 阅读 · 0 评论 -
python的主函数问题
当你打开一个.py文件时,经常会在代码的最下面看到if __name__ == '__main__':,现在就来介绍一下它的作用.每个文件都有一个内置的属性叫__name__,这个值取决于该文件如何执行。如果这个文件是直接执行的,__name__的值等于__main__;如果这个文件是被别的文件调用的,那么__name__值就是该文件的名字(不含后缀)。python在执行文件时,是没有主函原创 2017-09-04 15:31:22 · 2562 阅读 · 0 评论 -
python 赋值原理
在python中变量名相当于一个指针,为变量赋值相当于是将指针指向了这个值的内存空间。如图1那么如果执行foo1=foo2=4.3的时候相当于(参考《Python核心编程》第二版4.5.2)foo1 = 4.3foo2 = foo1按照这种理解,那么是不是如果继续执行foo1=5.0foo2 也会变成5.0呢?当然不会。(详细程序验证在下面)但是,如果变原创 2017-09-05 16:01:44 · 1668 阅读 · 0 评论 -
安装anaconda错误:failed to create anaconda menus
问题: 我的电脑是windows server 2008的,安装anaconda 64位 安装到最后出现 failed to create anaconda menus,图片参考的下面参考文献, 解决方法: 先安装Microsoft Visual C++ 2008 Redistributable Package (x64) https://www.microsoft转载 2017-11-30 09:39:41 · 4383 阅读 · 0 评论