![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
Jredreamer
这个作者很懒,什么都没留下…
展开
-
python发送各类邮件(转自:http://pythoner.net/code/51/)
来源:http://www.cnblogs.com/xiaowuyi/archive/2012/03/17/2404015.html python中email模块使得处理邮件变得比较简单,今天着重学习了一下发送邮件的具体做法,这里写写自己的的心得,也请高手给些指点。 一、相关模块介绍 发送邮件主要用到了smtplib和email两个模块,这里首先就两个模块进行一下简单的介绍: 1、转载 2013-02-25 13:40:51 · 820 阅读 · 0 评论 -
python 模拟分割大文件后,多线程处理
#!/usr/bin/env python#--*-- coding:utf-8 --*--from random import randintfrom time import ctimefrom time import sleepimport queueimport threadingclass MyTask(object): """具体的任务类""" def原创 2013-06-08 14:44:57 · 4543 阅读 · 0 评论 -
python3.2 threading 和 queue
#!/usr/bin/env python#--*-- coding:utf-8 --*--from random import randintfrom time import ctimefrom time import sleepimport queueimport threadingclass MyTask(object): def __init__(self, n原创 2013-06-07 19:16:43 · 7364 阅读 · 0 评论 -
python正则表达式例子
#!/usr/bin/env python#--*-- coding:utf-8 --*--import redef print_match(pattern_str, match_str): """打印match匹配的字段""" m = re.match(pattern_str, match_str) if m : print("YES -->p原创 2013-06-07 16:27:46 · 749 阅读 · 0 评论 -
python 的日志logging模块学习 (转自:http://www.cnblogs.com/dkblog/archive/2011/08/26/2155018.html)
1.简单的将日志打印到屏幕 import logginglogging.debug('This is debug message')logging.info('This is info message')logging.warning('This is warning message') 屏幕上打印:WARNING:root:转载 2013-06-05 18:18:16 · 927 阅读 · 0 评论 -
python3.3 装饰器日志
#!/usr/local/bin/Python3.3#-*-coding:utf-8-*-def log_none_params(func): ''' none params decorate function ''' def log(*args, **kargs): print("before func" + str(func)) try: return func(*原创 2013-06-05 13:39:56 · 2052 阅读 · 0 评论 -
python 遍历修改工程下所有CVS/Root文件
由于CVS修改,倒是现有工程无法提交已修改代码,而且也没有在Intell ida中找到修改全部CSV路径的方法,所以就写了个小脚本全给改了,哇嘎嘎~#!/usr/bin/env python#--*-- coding:utf-8 --*--import oslist_path = r"F:\IntelliJIDEA_workspace\maven\sgh_findgame"# o原创 2013-06-08 15:47:25 · 1481 阅读 · 0 评论 -
python 按行分割文件
#!/usr/bin/env python#--*-- coding:utf-8 --*--import osclass SplitFiles(): """按行分割文件""" def __init__(self, file_name, line_count=200): """初始化要分割的源文件名和分割后的文件行数""" self.fil原创 2013-06-08 14:30:15 · 11352 阅读 · 0 评论 -
python从共享目录读取考勤数据,通过openpyxl解析excel2007,查询出自己考勤记录
# -*- coding: utf-8 -*-""" Python3.2 operate Excel_2007"""import sysimport datetimefrom openpyxl import Workbookfrom openpyxl.cell import get_column_letterfrom openpyxl import load_workb原创 2013-05-14 15:59:58 · 2052 阅读 · 0 评论 -
python3.2 解析JSON
json.txt{ "programmers": [{ "firstName": "Brett", "lastName":"McLaughlin", "email": "aaaa" },{ "firstName": "Jason", "lastName":"Hunter", "email": "bbbb" },{ "firstName": "Elliotte", "lastName"原创 2013-05-13 18:52:00 · 1947 阅读 · 0 评论 -
python编码规范(转自:http://blog.csdn.net/yefengnidie/article/details/6721781)
标准头部#!/usr/bin/python编码所有的 Python 脚本文件都应在文件头标上 #-*- coding:utf8 -*- 。设置编辑器,默认保存为 utf8 格式。main函数应用程序要定义main函数而不要直接写脚本def main(): dosomething()if __name__ == "__main__": main()转载 2013-05-10 09:49:59 · 828 阅读 · 0 评论 -
python3.2 多线程小爬虫一只
# -*- coding:utf-8 -*-"""多线程抓取网页"""import gzipfrom urllib import request as urllib2import threadingfrom pyquery import PyQuery as pqthreads = []web_site_url = "http://www.oschina.net/ques原创 2013-05-16 13:06:37 · 2758 阅读 · 0 评论 -
python socket bind机器上所有ip的方法
转自:http://blog.csdn.net/powerccna/article/details/7760059python socket bind 可以指定IP, 但如果socket.bind(("192.168.22.112",8099)), 这样的话,127.0.0.1:8099, 或者localhost:8099都无法访问,bash-3.2# telnet 1转载 2013-05-16 18:59:55 · 3829 阅读 · 0 评论 -
python3.x 对 python2.x 语法变动
转自:http://hi.baidu.com/autoitcn/item/630dfbfe39b5f911fe35824dpython3.x 对 python2.x 语法变动python 2.4 与 python 3.0 的比较一、 print 从语句变为函数 原: print 1, 2+3改为: print ( 1, 2+3 )二、rang转载 2013-05-15 15:23:01 · 901 阅读 · 0 评论 -
第一个PyQuery完整抓取网页例子
#-*-coding:utf-8-*-from pyquery import PyQuery as pqimport CommonUtils'''搞趣网抓取'''def parseGao7(url='http://www.gao7.com/free/1-0-0-3-0-0-1') : result=[] data=pq(url) if data :原创 2013-04-27 18:41:28 · 2612 阅读 · 0 评论 -
python抓取时gzip解压
'''根据URL返回内容,有些页面可能需要gzip解压缩'''def getUrlContent(url): #返回页面内容 doc = urllib.request.urlopen(url).read() #解码 try: html=gzip.decompress(doc).decode("utf-8") except:转载 2013-04-27 17:28:51 · 3945 阅读 · 0 评论 -
python抓取网页
#-*- coding:utf8 -*-import urllib.parseimport urllib.request'''根据返回数据获取网页编码格式'''def getCharSet(response) : contype = response.headers['Content-Type'] pos = contype.find('=') if -1原创 2013-04-26 20:01:38 · 786 阅读 · 0 评论 -
python2.4 解析json数据
转自:http://blog.csdn.net/azhao_dn/article/details/7020280python2.4版本解析json格式数据的快速方法: json = “{'body': '\xc3\xb2\xc2\x85\\u0003', 'timestamp': 1322510400069L, 'pri': 'INFO', 'nanos': 12转载 2013-07-24 10:07:37 · 2060 阅读 · 0 评论