__author__?=?‘baron‘
import?os
import?codecs
from?os.path?import?join,?getsize
def?getdirsize(dirDict,?rootpath):
????dirsize?=?0L
????for?root,?dirs,?files?in?os.walk(r...
分类:
编程语言 时间:
2015-09-24 16:44:14
阅读次数:
204
import os def list_dir(dir): all_dirs = [] for root, dirs, files in os.walk('./', True): for name in dirs: cur_dir = os.path.join(root,name) if cur_di...
分类:
其他好文 时间:
2015-09-15 17:54:48
阅读次数:
148
import?ConfigParser
import?os
import?sys
cf?=?ConfigParser.ConfigParser()
#绝对路径获取
ABSPATH=os.path.abspath(sys.argv[0])
ABSPATH=os.path.dirname(ABSPATH)+"/"
cf.read(ABSPATH?+‘digest....
分类:
编程语言 时间:
2015-09-15 11:13:28
阅读次数:
171
#!/usr/bin/envpython
importxlsxwriter,xlrd
importsys,os.path
reload(sys)
sys.setdefaultencoding(‘utf8‘)
defMergeExcelToWorksheet(*arg):
lfile=arg
fname={}
worksheet={}
forhinlfile:
fname[h]=h
printh
data=xlrd.open_workbook(fname[h])#打开fname文件..
分类:
其他好文 时间:
2015-09-10 17:47:15
阅读次数:
186
今天开始学习Python写个爬虫。首先,从百度找个实例来看看。1importurllib.request,re,sys,os2defget_bing_backphoto():3if(os.path.exists('photos')==False):4os.mkdir('photos')5foriin...
分类:
编程语言 时间:
2015-09-10 11:03:12
阅读次数:
220
链接:http://demo.pythoner.com/itt2zh/ch2.html 来到了第二章;模板与表单 1 # -*- coding:utf-8 -*- 2 3 __author__ = 'roy' 4 5 import os.path 6 7 import tornado.h...
分类:
其他好文 时间:
2015-09-08 20:00:42
阅读次数:
199
不定参数介绍元组参数字典参数混合介绍不定参数用 * 和 ** 定义不定参数必须在其他所有参数之后例子:os.path.join 方法就可以写入不定数量的参数元组参数定义:*args 以*作为参数前缀会将传入的多个参数作为一个元组传入代码def fun(*args): for i in args...
分类:
编程语言 时间:
2015-08-31 23:33:29
阅读次数:
307
Python获取程序运行目录和脚本目录importosimportsys#获取脚本所在目录printos.path.split(os.path.realpath(sys.argv[0]))[0]#获取脚本运行目录printos.getcwd()在脚本所在目录运行: python test.py/ho...
分类:
编程语言 时间:
2015-08-30 19:27:14
阅读次数:
181
这个获取文件路径中所在的目录。1234567In[1]:importosIn[2]:os.__file__Out[2]:'/usr/lib/python2.7/os.pyc'In[3]:os.path.dirname(os.__file__)Out[3]:'/usr/lib/python2.7'
分类:
编程语言 时间:
2015-08-21 12:44:54
阅读次数:
120