Python开发Activex组件
Python强的功能就在于它无所不能。
使用win32com模块开发window ActiveX的示例:(如果你还没有装win32com模块的话,请到http://python.net/crew/skippy/win32/Downloads.html下载)。
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
_reg_clsid_ = "{A6688635-62F5-41cb-AF54-CBA84C2F0F86}"
def SplitString(self, val):
return "Hello world ", val
if __name__ == '__main__':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtilities)
在console下运行:python SimpleCOMServer.py
在HTML页面中调用该Activex组件:
window.onload = function(){
var obj = new ActiveXObject("Python.Utilities");
alert(obj.SplitString("Hel"));
}
相关文档:
这个代码是基于python3.0写的,有许多不完善的地方,请自已修改。
# coding: utf-8
from tkinter import *
root = Tk()
root.title("python3.0查询")
#root.minsize(800,600)
#填充无用空间
Label(root).grid(ipady=5)
#11面板
class Frame11:
def __init__(self, root): # ......
在Python中,我们执行表达式 a = 3,Python会怎样操作呢?
1、首先会创建一个对象表示值3
2、如果变量a不存在,创建变量a
3、把变量a连接到表示3的对象
在Python中,变量和对象存储在不同的地方,通过指针连接起来...
一个变量总是和对象连接起来,不存在不和对象连接的变量,但是大的对象可能连接到别的对象。 ......
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough t ......
1.Python的扩展
Python扩展是指运用其他语言编写某些功能模块,供Python程序调用,常用的有Python的C扩展和C++扩展。Python扩展的目的主要有两个:一是为了功能需要,另外一个原因是为了性能需要。下面介绍一下在不运用工具的情况下,运用C和C++语言对Python进行扩展的步骤。
扩展的第一步是用C或C++创建一个源程序,然后 ......
两种不同的语言,不同的表达!
Python脚本实现.
""
"
File Name : clean.py
File Date : 2009/11/5 14:22:56
Author : DannyLai
Purpose : Cle ......