複製代碼 代碼如下:#Filename:brn.py #Description: batch replace certain words in file names #Use to bat rename the file in a dir(modify the suffix from a to b) for Windows Vista OS import sys import os import fnmatch import re #parse params p=input("Please
複製代碼 代碼如下:# coding=utf-8 from BeautifulSoup import BeautifulSoup, Tag, NavigableString from SentenceSpliter import SentenceSpliter from os.path import basename,dirname,isdir,isfile from os import makedirs from shutil import copyfile import io import
def cndebug(obj=False): """ Author : Nemon Update : 2009.7.1 TO use : cndebug(obj) or cndebug() or MyObject.debug=cndebug License: GPL """ print('='*80) print('='*30 + ' GLOBAL VARIABLES ' +'='*30) print('='*80) g=globals() for x,y in g.iteritems():
複製代碼 代碼如下:def find_file_by_pattern(pattern='.*', base=".", circle=True): '''''尋找給定檔案夾下面所有 ''' re_file = re.compile(pattern) if base == ".": base = os.getcwd() final_file_list = [] print base cur_list = os.listdir(base) for item in cur_list: if item =
opts, args = getopt.getopt(sys.argv[1:], "t:s:h", ["walletype=", "servicename=",'help']) for a,o in opts: if a in ('-t', '--walletype'): walle_type = o elif a in ('-s', '--servicename'): service_name = o elif a in ('-h', '--help'): help = True 其中t:s:
ip正則式為:r'(([12][0-9][0-9]|[1-9][0-9]|[1-9])\.){3,3}([12][0-9][0-9]|[1-9][0-9]|[1-9])' 以下為一個樣本 #-*- coding:utf-8 -*- import re def ip(): '驗證IP的正則式' def match_group(p): s = '''211.210.209.108 gan ffad1.210.2.108 d ffad1.210.2.109afa''' com =