Python脚本模板
1.Python脚本规范基础模板
#coding:utf8 import time, re, os, sys, time,urllib2,shutil,string import json,datetime #设置utf-8编码格式 reload(sys) sys.setdefaultencoding( "utf-8" ) #获取当前日期的前n天 def getbeforeDay(n=0): now_time = datetime.datetime.now() beforeday = now_time - datetime.timedelta(n) return beforeday.strftime("%Y%m%d") scriptDir = os.getcwd() if len(sys.argv) > 1 : job_date_id = sys.argv[1] else : job_date_id = getbeforeDay(0) print "当前脚本路径:%s,当前参数日期:%s" % (scriptDir,job_date_id)