![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
xiecj_2006
这个作者很懒,什么都没留下…
展开
-
Python日志定义
Python日志设置定义:logpath = "日期.log"log_mode = 'a'log_level = logging.DEBUGlog_format = '%(asctime)s %(levelname)-10s[%(filename)s:%(lineno)d(%(funcName)s)] %(message)s'Logger = logging.getLogger转载 2014-12-20 19:41:09 · 476 阅读 · 0 评论 -
进程示例之四----闹铃
摘录python标准库:import signalimport timedef receive_alarm(signum, stack): print 'Alarm:', time.ctime()signal.signal(signal.SIGALRM, receive_alarm)signal.alarm(2)print原创 2015-01-01 08:38:01 · 532 阅读 · 0 评论 -
文件目录操作一----------文件复制
原创 2015-01-01 16:31:05 · 334 阅读 · 0 评论 -
文件目录操作二----------目录创建删除显示
原创 2015-01-01 16:58:09 · 626 阅读 · 0 评论 -
python先进先出Queue
原创 2015-01-01 18:17:19 · 3283 阅读 · 0 评论 -
python动态加载包
python动态加载包分类: python2011-09-14 22:18 1684人阅读 评论(0) 收藏 举报pythonimportstringlistclassmodule动态加载模块有三种方法1,使用系统函数__import_()stringmodule = __import__('string')2,使用imp 模块import im转载 2015-01-01 19:46:03 · 1485 阅读 · 0 评论 -
Python网络爬虫(二)-----发送数据
1. 发送数据准备2. 发送数据原创 2015-01-02 10:52:06 · 1181 阅读 · 0 评论 -
Python网络爬虫(六)-----HTTPBasicAuthHandler认证
1. 失败2. 成功原创 2015-01-02 14:37:51 · 4795 阅读 · 0 评论 -
python解压缩zip文件
文件代码:[root@jenkins chap10]# cat unzipfile.pyimport zipfilewith zipfile.ZipFile('subprocess.zip', 'r') as zf: print zf.namelist() for file in zf.namelist(): zf.extract(file原创 2015-01-01 09:30:04 · 568 阅读 · 0 评论 -
python有序字典
代码:# -*- coding: UTF-8 -*-import collectionsprint 'Regular dictionary:'d = {}d['a'] = 'A'd['b'] = 'B'd['c'] = 'C'for k, v in d.items(): print k, v print '\nOrderedD原创 2015-01-01 18:08:22 · 1215 阅读 · 0 评论 -
Python网络爬虫(四)-----异常处理
参考:http://www.voidspace.org.uk/python/articles/urllib2.shtml#openers-and-handlers http://blog.csdn.net/pleasecallmewhy/article/details/8924889原创 2015-01-02 11:00:11 · 849 阅读 · 0 评论 -
Python ftp操作之一-------linux vsftp搭建
1. 安装vsftpd,可使用rpm包安装2. 关闭防火墙3. 设置ftp匿名登录4. 启动vsftp5. 访问ftp原创 2015-01-03 17:30:01 · 943 阅读 · 0 评论 -
Python网络爬虫(一)-----获取网页数据
参考:http://www.voidspace.org.uk/python/articles/urllib2.shtml#openers-and-handlers http://blog.csdn.net/pleasecallmewhy/article/details/8924889原创 2015-01-02 10:51:03 · 7130 阅读 · 0 评论 -
Python网络爬虫(三)-----User-Agent
1. 查看URL, User-Agent2. User-Agent提交3. 网页返回数据原创 2015-01-02 10:44:05 · 9447 阅读 · 0 评论 -
Python网络爬虫(五)-----geturl及info
参考:http://www.voidspace.org.uk/python/articles/urllib2.shtml#openers-and-handlers http://blog.csdn.net/pleasecallmewhy/article/details/8924889原创 2015-01-02 13:07:10 · 5642 阅读 · 0 评论 -
进程示例之一----连接管道
import subprocesscat = subprocess.Popen(['cat', 'subprocess_signal_setsid.py'], stdout=subprocess.PIPE, )grep = subprocess.Popen(['grep', 'su原创 2015-01-01 08:12:53 · 636 阅读 · 0 评论 -
进程示例之三----进程组之间的信号传递
import osimport signalimport subprocessimport tempfileimport timeimport sysscript = '''#!/bin/shecho "Shell script in process $$"set -xpython signal_child.py'''script_fil原创 2015-01-01 07:50:36 · 581 阅读 · 0 评论 -
进程示例之二----进程间的信号传递
linux下,示例来自python标准库:1. signal_child.py2. signal_parent.py3. 执行原创 2014-12-29 22:34:23 · 374 阅读 · 0 评论 -
python使用urllib下载ftp文件
ftp请参照vsftp设置,随意上传文件再下载import urlliburl = 'ftp://192.168.1.10/pub/1/1.jpg'local='c://1.jpg'urllib.urlretrieve(url, local)原创 2015-01-06 21:02:08 · 1977 阅读 · 0 评论 -
python的优先队列示例
来自python标准库1. 代码2. 执行结果原创 2015-01-06 20:08:33 · 14831 阅读 · 0 评论 -
soaplib webservices的hello world
# -*- coding: UTF-8 -*-import soaplibfrom soaplib.core.service import rpc, DefinitionBase, soapfrom soaplib.core.model.primitive import String, Integerfrom soaplib.core.server import wsgi原创 2014-12-21 10:14:01 · 977 阅读 · 0 评论 -
pyquery: 基于python和jquery语法操作XML
内容属性 (Attributes)转换 (Traversing)AJAX使用不同的解析器更多的文档pyquery.pyquery – PyQuery 完全 API 手册用法Attributes样式表 (CSS)转换 (Traversing)操作 (Manipulating)AJAX生成绝对链接使用不同的解析器测试更多文档TODOpyquery.pyquery – PyQue转载 2014-12-21 15:35:19 · 1199 阅读 · 0 评论 -
pyquery解析ALM描述字段
原创 2014-12-22 19:34:14 · 370 阅读 · 0 评论 -
Python模块学习 ---- threading 多线程控制和处理
Thread 是threading模块中最重要的类之一,可以使用它来创建线程。有两种方式来创建线程:一种是通过继承Thread类,重写它的run方法;另一种是创建一个threading.Thread对象,在它的初始化函数(__init__)中将可调用对象作为参数传入。下面分别举例说明。先来看看通过继承threading.Thread类来创建线程的例子:#coding=g转载 2014-12-23 20:54:56 · 527 阅读 · 0 评论 -
rpyc的使用
连接时,会提示on_connect,断开连接时会打印on_disconnect,调用get_answer方法时会提示42原创 2014-12-23 21:09:15 · 1330 阅读 · 0 评论 -
pyodbc数据库连接sqlserver数据库
import pyodbcdef connMsSql(Cfg): conn_info = "DRIVER={SQL Server};DATABASE=%s;SERVER=%s;UID=%s;PWD=%s" % (Cfg['DATABASE'], Cfg['SERVER'], Cfg['UID'], Cfg['PWD']) conn = pyodbc.connect(原创 2014-12-23 21:33:57 · 3496 阅读 · 0 评论 -
获取文件信息
用于判断文件大小,创建,修改时间等等,比如:删除 Wed Nov 26 23:50:15 2014创建的文件。原创 2014-12-23 21:56:41 · 316 阅读 · 0 评论 -
Python编码
原创 2014-12-24 20:17:53 · 412 阅读 · 0 评论 -
xml.etree.ElementTree — The ElementTree XML API
New in version 2.5.Source code: Lib/xml/etree/ElementTree.pyThe Element type is a flexible container object, designed to store hierarchical data structures in memory. The type can be des转载 2014-12-26 20:47:28 · 1497 阅读 · 0 评论 -
ConfigParser — Configuration file parser
Note The ConfigParser module has been renamed to configparser in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.This module defines t转载 2014-12-26 20:43:02 · 2179 阅读 · 0 评论 -
python上下文管理器及with语句
with语句支持在一个叫上下文管理器的对象的控制下执行一系列语句,语法大概如下:12with context as var: statements其中的context必须是个上下文管理器,它实现了两个方法__enter__,__exit__。1.需求是怎么产生的在正转载 2015-01-15 21:18:55 · 6246 阅读 · 0 评论 -
python压缩zip文件
1. 获取zip信息2. 压缩3. 执行原创 2015-01-01 09:16:54 · 423 阅读 · 0 评论 -
Python ftp操作之二-------上传下载
1. ftp基本操作,代码很乱,仅供参考2. 文件上传下载结果,请参考文件时间原创 2015-01-03 17:28:47 · 549 阅读 · 0 评论