Python
Tcorpion
写着代码,喜欢着东方姑娘,陈乔恩
展开
-
python try except else finally 执行顺序详细分析
学习python或者其他有异常控制的编程语言, 大家很有可能说try except finally(try catch finally)的执行很简单,无非就是有异常的话执行except, finally无论是否有异常都会执行, 大致上原则是这样, 但是如果涉及到更加详细的复杂的路径,加上return 语句,就没有那么简单了。1. 没有return 语句的情况转载 2017-04-09 17:29:09 · 496 阅读 · 0 评论 -
python 去除空格/换行符
s = "as, asdas \r\nasda" print s.split(); # result: ['as,', 'asdas', 'asda'] print "".join(s.split()); # result: as,asdasasda l = "".join(s.split()).split(',')转载 2017-07-19 22:32:24 · 2482 阅读 · 1 评论 -
快速近似最近邻搜索库 FLANN - Fast Library for Approximate Nearest Neighbors
What is FLANN?FLANN is a library for performing fast approximate nearest neighbor searches in high dimensional spaces. It contains a collection of algorithms we found to work best for nearest neig转载 2017-08-17 11:24:26 · 2136 阅读 · 0 评论 -
optparse模块OptionParser学习
optparse是专门用来在命令行添加选项的一个模块。首先来看一段示例代码from optparse import OptionParserMSG_USAGE = "myprog[ -f ][-s ] arg1[,arg2..]"optParser = OptionParser(MSG_USAGE)optParser.add_转载 2017-08-18 17:50:26 · 1162 阅读 · 0 评论 -
openCV3 在ubuntu14上的配置
参考:1. http://www.cnblogs.com/asmer-stone/p/5089764.html2. http://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html原创 2017-07-25 22:45:28 · 694 阅读 · 0 评论 -
Python 模块学习:os模块(转)
转摘于: http://www.cnblogs.com/BeginMan/p/3327291.html(原文链接)一、os模块概述Python os模块包含普遍的操作系统功能。如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的。(一语中的)二、常用方法1、os.name输出字符串指示正在使用的平台。如果是window 则用'nt'表示,对于Linux/Unix用户,转载 2016-09-06 16:18:49 · 354 阅读 · 0 评论 -
Python多进程应用的subprocess模块、multiprocessing模块
refer: http://www.cnblogs.com/sunailong/p/5162748.html 我很懒的原创 2017-08-17 22:06:04 · 2725 阅读 · 0 评论 -
argparse模块学习
查看原文:http://www.sijitao.net/2000.htmlpython中的命令行解析最简单最原始的方法是使用sys.argv来实现,更高级的可以使用argparse这个模块。argparse从python 2.7开始被加入到标准库中,所以如果你的python版本还在2.7以下,那么需要先手动安装。基本使用import argparse parser=argparse转载 2017-10-20 21:28:07 · 320 阅读 · 0 评论 -
pip切换国内源
1-step:sudo mkdir ~/.pip/sudo gedit ~/.pip/pip.conf2-step:# add in ~/.pip/pip.conf[global]trusted-host=mirrors.aliyun.comindex-url=http://mirrors.aliyun.com/pypi/simple/原创 2018-07-25 22:21:09 · 558 阅读 · 0 评论 -
flask记录
1. 官网 http://flask.pocoo.org/docs/1.0/quickstart/#deploying-to-a-web-server原创 2018-08-15 23:37:28 · 235 阅读 · 0 评论 -
Python正则表达式
from: http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html本文介绍了Python对于正则表达式的支持,包括正则表达式基础以及Python正则表达式标准库的完整介绍及使用示例。本文的内容不包括如何编写高效的正则表达式、如何优化正则表达式,这些主题请查看其他教程。注意:本文基于Python2.4完成;如果看转载 2017-07-19 18:54:51 · 227 阅读 · 0 评论 -
python持久化模块:pickle和Cpickle
from: http://www.cnblogs.com/pannyvan/p/4439308.html经常遇到在Python程序运行中得到了一些字符串、列表、字典等数据,想要长久的保存下来,方便以后使用,而不是简单的放入内存中关机断电就丢失数据。这个时候Pickle模块就派上用场了,它可以将对象转换为一种可以传输或存储的格式。 python的pickle模块实现了转载 2017-07-19 15:50:14 · 975 阅读 · 0 评论 -
python解析XML:ElementTree(元素树)
ElementTree就像一个轻量级的DOM,具有方便友好的API。代码可用性好,速度快,消耗内存少。 hzj man kiki female 1.加载xml文件 加载XML文件共有2种方法,一是加载指定字符串,二是加载指定文件2.获取ele转载 2017-04-13 14:59:29 · 3998 阅读 · 0 评论 -
Python-第三方库requests详解
Requests 是用Python语言编写,基于 urllib,采用 Apache2 Licensed 开源协议的 HTTP 库。它比 urllib 更加方便,可以节约我们大量的工作,完全满足 HTTP测试需求。Requests 的哲学是以 PEP 20 的习语为中心开发的,所以它比 urllib 更加 Pythoner。更重要的一点是它支持 Python3 哦!Beaut转载 2017-04-18 15:26:19 · 701 阅读 · 0 评论 -
利用Requests爬取图片和文本--博主比较懒
利用Requests爬取图片原创 2017-04-18 16:01:49 · 1018 阅读 · 3 评论 -
python常见的错误类型和继承关系
The class hierarchy for built-in exceptions is:BaseException +-- SystemExit +-- KeyboardInterrupt +-- GeneratorExit +-- Exception +-- StopIteration +-- StandardError |转载 2017-04-14 16:15:07 · 698 阅读 · 0 评论 -
Python错误: SyntaxError: Non-ASCII character
(1)问题描述 在写Python代码的过程中,有用到需要输出中文的地方,但是运行后发现上述错误。 SyntaxError: Non-ASCII character '\xe4' in file ./common.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html转载 2017-04-14 16:37:04 · 481 阅读 · 0 评论 -
Scrapy官网tutorial、Requests官网文档、lxml官方文档、XPath语法、python核心模块pickle和cPickle讲解
博主比较懒,参考下面链接lxml官方文档: http://lxml.de/tutorial.htmlXPath语法:http://www.w3school.com.cn/xpath/xpath_syntax.asppython核心模块之pickle和cPickle讲解:http://www.pythonclub.org/modules/pickle原创 2017-04-18 17:12:43 · 942 阅读 · 0 评论 -
Python 2.7.x 和 3.x 版本的重要区别小结
from: http://www.jb51.net/article/57956.htm详见上面链接转载 2017-07-20 15:28:19 · 1003 阅读 · 0 评论 -
python对xml文件写入操作
#Python写xml比较简单,直接使用xml模块的minidom即可对xml文件进行写入操作 from xml.dom.minidom import Document doc = Document() people = doc.createElement("people") doc.appendChild(people) aperson = do原创 2017-07-17 15:36:51 · 7114 阅读 · 0 评论 -
Python中dom写xml,含属性设置
from: http://blog.csdn.net/fhl812432059/article/details/51647529dom写xml 1.引入包import xml.dom.minidom2.writexml方法writexml(writer, indent, addindent, newl, encoding)writer是文件对象indent是转载 2017-07-17 15:57:07 · 5192 阅读 · 1 评论 -
Python 的默认日志模块logging
我很懒,亲,看这里:https://www.cnblogs.com/Nicholas0707/p/9021672.htmlhttps://www.cnblogs.com/nancyzhu/p/8551506.html按天分割日志保留七天记录。留一段备用,(实际使用日志分割并没准确按天分,可能会漏分割)import loggingfrom logging.handlers imp...转载 2018-09-26 21:46:22 · 537 阅读 · 0 评论