This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
class _Getch: | |
"""Gets a single character from standard input. Does not echo to the screen.""" | |
def __init__(self): | |
try: | |
self.impl = _GetchWindows() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
import urllib2 | |
import re | |
# get page html | |
page = urllib2.urlopen("http://photography.nationalgeographic.com/ngs_pod_ext/searchPOD.jsp?month=06&day=10&year=2009&page=") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
import os | |
import sys | |
import errno | |
import logging | |
import logging.handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
import matplotlib | |
from pylab import plot | |
import sys,math | |
# get current tolerance level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import re,time | |
def get_net_info(): | |
flow1 = open('/proc/net/dev') | |
lines = flow1.read() | |
flow1.close() | |
e = re.compile('(eth.)') | |
r_re = re.compile('eth..(.*?\s)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
from os.path import basename, isdir | |
from os import listdir | |
def traverse(path, depth=0): | |
print depth* '| ' + '|_', basename(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import urllib, urllib2, cookielib, hashlib,threading | |
import re, os, time, random | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
def log(s): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:UTF8 -*- | |
#1.概念: | |
# 正则表达式(或 RE)是一种小型的、高度专业化的编程语言, | |
# (在Python中)它内嵌在Python中,并通过 re 模块实现。使用这个小型语言, | |
# 你可以为想要匹配的相应字符串集指定规则;该字符串集可能包含英文语句、email | |
# 地址、TeX命令或任何你想搞定的东西。然后你可以问诸如“这个字符串匹配 | |
# 该模式吗?”或“在这个字符串中是否有部分匹配该模式呢?”。你也可以使用 RE | |
# 以各种方式来修改或分割字符串。 | |
# | |
# 正则表达式语言相对小型和受限(功能有限),因此并非所有字符串处理都能用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf-8') | |
import os | |
import sys | |
def Show_file(): | |
print "lines filename" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf-8') | |
''' | |
Created on 2012-3-13 | |
@author: 小马过河 | |
''' |