易截截图软件、单文件、免安装、纯绿色、仅160KB

Python 处理excel并转为table

使用xlrd

读取,xlrd的下载及安装可以参看:
Python
"xlrd" package for extracting data from Excel files
---------------------------------------------------------------------------------
#coding=utf-8
import xlrd
import os, types, datetime
#excel存放目录
dir = u'D:\\temp\\excel'
#生成html存放目录,需要事先建立
htmlroot = u'D:\\temp\\html'
#excel从1899/12/31计算时间
__s_date = datetime.date(1899, 12, 31).toordinal() - 1
#读取时间格式的单元
def getdate(date):
    if isinstance(date, float):
        date = int(date)
    d = datetime.date.fromordinal(__s_date + date)
    return d.strftime("%Y-%m-%d")
#遍历文件夹
for root, dirs, files in os.walk(dir):
    for file in files:
        #生成excel文件路径
        path = os.path.join(root, file)
        print u'converting...   ' + path
      
        book = xlrd.open_workbook(path) #打开excel文件
      
        #遍历excel文件中的sheet
        for shn in range(book.nsheets):
            sh = book.sheet_by_index(shn)
            #判断该表是否为空
            if sh.nrows == 0:
                continue
          
            #搜索“路径”列
 &nbs


相关文档:

手动制作python的exe可执行程序


1. 手动制作python的exe可执行程序
                                      转载---------------
Python没有内建一个编 ......

深入Python摘要

英文版Dive in python可以在下面找到中文翻译http://linuxtoy.org/docs/dip/toc/index.html
模块的__name__,当模块被import时,其为模块的名字,当模块作为main执行的时候,其为__main__
词典的key是大小写敏感的。
List也支持重载+操作,用于将两个list连接起来,并返回一个List,因此它没有extended执行高效。list也+ ......

用Python直接写UTF 8文本文件

当我们这样建立文件时
f =
file('x1.txt', 'w')
f.write(u'中文')
f.colse()

接结果应该是类似
    f.write(u'中文')
UnicodeEncodeError: 'ascii'
codec can't encode characters in position 0-16: ordinal not in
range(128)
要直接写 utf-8 文件怎么办呢?
import codecs
f = codecs. ......

python读取目录下文件并生成日志

很长的一段代码,但很清楚。哈哈。
import os
from time import strftime
stamp=strftime("%Y-%m-%d %H:%M:%S")
logfile = 'F:\\test\\m-php-framework\\tmp\logs\\error_report.log'
path = 'F:\\test\\'
files = os.listdir(path)
bytes = 0
numfiles = 0
for f in files:
if f.startswith('t'): ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号