随笔分类 -  python

摘要:“UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xb0 in position 1: ordinal not in range(128)” 在windows XP上解决方法:Solution:======================I... 阅读全文
posted @ 2014-12-03 14:35 silence.li 阅读(278) 评论(0) 推荐(0)
摘要:http://www.crifan.com/python_auto_handle_cookie_and_save_to_from_cookie_file/#!/usr/bin/python# -*- coding: utf-8 -*-"""Function: 【整理】Python中Cookie的... 阅读全文
posted @ 2014-08-22 17:22 silence.li 阅读(1149) 评论(0) 推荐(0)
摘要:#!/usr/bin/python 2 import urllib 3 import urllib2 4 import re 5 import os 6 7 dirs = ['js','img','pay','css'] 8 urls = ['http://www.xxxxxx.net/' + x for x in dirs] 9 10 def parse(baseurl): 11 url_hand = urllib2.urlopen(baseurl) 12 url_cont = url_hand.read() 1 阅读全文
posted @ 2014-03-27 17:23 silence.li 阅读(248) 评论(0) 推荐(0)
摘要:http://red2.sunderland.ac.uk/python/genindex.htmlhttp://www.adminsehow.com/2011/09/iptables-packet-traverse-map/mysql:http://imysql.com/linux kernelht... 阅读全文
posted @ 2014-03-19 15:24 silence.li 阅读(257) 评论(0) 推荐(0)
摘要:ljust用法:string.ljust(number,'x')格式化输出字符串,按照number数量调整字符串的总长度,ljust是左对齐,‘x’是填充字符,默认是空格类似的还有rjust,center 阅读全文
posted @ 2014-03-18 11:11 silence.li 阅读(601) 评论(0) 推荐(0)
摘要:#!/usr/bin/python #-*- coding: utf-8 -*-import osimport rerawfile = '/var/log/auth.log'def rawparse(rawfile): ipdict = {} fhandle = open(rawfile,'r') regexp = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') for line in fhandle: result = regexp.findall(line) if result and i.. 阅读全文
posted @ 2014-02-14 14:05 silence.li 阅读(456) 评论(1) 推荐(0)
摘要:import osdef listdirs(base): for line in os.listdir(base): fullpath = os.path.join(base,line) if os.path.isdir(fullpath): listdirs(fullpath) elif os.path.isfile(fullpath): print fullpathbase = r'C:\Program Files\SogouInput\Components'listdirs(base) 阅读全文
posted @ 2014-02-10 14:19 silence.li 阅读(661) 评论(0) 推荐(0)
摘要:删除qq文件夹中2013年12-31之前的文件import osimport timeimport datetimetimeline = datetime.datetime(2013,12,31)tl = time.mktime(timeline.timetuple())rootdir = r'C:\Documents and Settings\Administrator.CHINA-C58199F8B\My Documents\Tencent Files\xxxxxxxx\Image'for basedirs, dirs, files in os.walk(rootdir): 阅读全文
posted @ 2014-02-10 12:32 silence.li 阅读(568) 评论(0) 推荐(0)
摘要:同事要求在ubuntu12.04上安装python模块,log4py, bs4, lxml, threadpool, pycurl有三种方法:1.apt-get install xxxx 2.使用pip安装 3.下载压缩包,使用install安装bs4apt-cache search python-bs4apt-get install python-bs4lxmlapt-get install python-lxmllog4pywget http://ufpr.dl.sourceforge.net/sourceforge/log4py/log4py-1.3.tar.gzta... 阅读全文
posted @ 2013-11-13 17:12 silence.li 阅读(1524) 评论(1) 推荐(0)