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

python操作excel


既然选择了远方,就必须日夜兼程 http://wrsuifeng.javaeye.com
Python代码
# Filename: excel.py   
import os,sys,time   
import win32com.client   
import traceback   
  
excel = win32com.client.Dispatch("Excel.Application")   
filename = "D:\\test.xls"  
  
try:   
    d1 = excel.Workbooks.Add()   
    sheet = d1.Sheets(1)   
       
    for i in xrange(1,10):   
        for j in xrange(1,10):   
            sheet.Cells(i,j).Value = str(i*j)   
    d1.SaveAs(filename)   
except Exception, e:   
    print traceback.print_exc()   
    print e   
       
excel.Quit()  


相关文档:

python动态导入模块、检查模块是否安装

参考链接:http://www.woodpecker.org.cn/diveintopython/functional_programming/dynamic_import.html
一 动态导入模块
Python的import不能接受变量,所以应该用 __import__函数来动态导入。
如下的代码无法正常导入模块
modules = ['OpenSSL', 'Crypto', 'MySQLdb', 'sqlite3', 'zope.interface', 'pyasn1', 'twisted ......

Python GTK+ 开发文档

1. Building an Application with PyGTK and Glade
2. Creating a GUI using PyGTK and Glade
3. A Beginner's Guide to Using pyGTK and Glade
4. Is there a walkthrough on getting PyGTK2 and libglade2 to work on win32 ......

python之学习类:python修改文件名


下面是对某文件夹下多个文件下指定文件换名字的实例(为了换名字,因为懒得手动改,折腾了一会搞出来的)
原理很简单,换文件名的话指定path就行 ,具体的自己看吧,仅供参考!
#-*- coding:utf-8 -*-
import os,sys
#=======================================
##对多个文件夹下的文件(夹)进行处理
#============ ......

python读写二进制文件

初学python,现在要读一个二进制文件,查找doc只发现file提供了一个read和write函数,而且读写的都是字符串,如果只是读写char等一个字节的还行,要想读写如int,double等多字节数据就不方便了。在网上查到一篇贴子,使用struct模块里面的pack和unpack函数进行读写。下面就自己写代码验证一下。
>>> from struct ......

PDF自动改名的Python程序


下载的PDF文档中有的命名很乱,就想起了自己写个程序,然后读取PDF的title属xing,根据这个属xing,更改次文档的名字!以下是代码:
需要到:http://pybrary.net/pyPdf/上面下载对应平台的PDF的库文件,然后安装,导入。
#encoding:utf-8
import os
import operator
from pyPdf import PdfFileWriter, PdfFileReader ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号