Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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"));
}


Ïà¹ØÎĵµ£º

python´¦ÀízipÎļþ£¨×ª£© 2009

 ×ª×Ô http://hi.baidu.com/xunxun129/blog/item/3befad0f8ff992c07bcbe180.html
ÓÐʱÎÒÃÇÐèÒªÔÚ Python
ÖÐʹÓà zip Îļþ£¬¶øÔÚ1.6°æÖУ¬Python ¾ÍÒѾ­ÌṩÁË zipfile Ä£¿é¿ÉÒÔ½øÐÐÕâÑùµÄ²Ù×÷¡£²»¹ý Python ÖеÄ
zipfile Ä£¿é²»ÄÜ´¦Àí¶à¾íµÄÇé¿ö£¬²»¹ýÕâÖÖÇé¿ö²¢²»¶à¼û£¬Òò´ËÔÚͨ³£Çé¿öÏÂÒѾ­×㹻ʹÓÃÁË¡£ÏÂÃæÎÒÖ»Ê ......

PythonÖеĶÔÏó¡¢±äÁ¿¼°ÒýÓÃ

  ÔÚPythonÖУ¬ÎÒÃÇÖ´Ðбí´ïʽ a = 3£¬Python»áÔõÑù²Ù×÷ÄØ£¿
1¡¢Ê×ÏȻᴴ½¨Ò»¸ö¶ÔÏó±íʾֵ3
2¡¢Èç¹û±äÁ¿a²»´æÔÚ£¬´´½¨±äÁ¿a
3¡¢°Ñ±äÁ¿aÁ¬½Óµ½±íʾ3µÄ¶ÔÏó
ÔÚPythonÖУ¬±äÁ¿ºÍ¶ÔÏó´æ´¢ÔÚ²»Í¬µÄµØ·½£¬Í¨¹ýÖ¸ÕëÁ¬½ÓÆðÀ´...
Ò»¸ö±äÁ¿×ÜÊǺͶÔÏóÁ¬½ÓÆðÀ´£¬²»´æÔÚ²»ºÍ¶ÔÏóÁ¬½ÓµÄ±äÁ¿£¬µ«ÊÇ´óµÄ¶ÔÏó¿ÉÄÜÁ¬½Óµ½±ðµÄ¶ÔÏó¡£ ......

Python¶ÁдÎļþ


PythonÖÐÎļþ²Ù×÷¿ÉÒÔͨ¹ýopenº¯Êý£¬ÕâµÄÈ·ºÜÏñCÓïÑÔÖеÄfopen¡£Í¨¹ýopenº¯Êý»ñÈ¡Ò»¸öfile object£¬È»ºóµ÷ÓÃread()£¬write()µÈ·½·¨¶ÔÎļþ½øÐжÁд²Ù×÷¡£
1.open
ʹÓÃopen´ò¿ªÎļþºóÒ»¶¨Òª¼ÇµÃµ÷ÓÃÎļþ¶ÔÏóµÄclose()·½·¨¡£±ÈÈç¿ÉÒÔÓÃtry/finallyÓï¾äÀ´È·±£×îºóÄܹرÕÎļþ¡£
file_object = open('thefile.txt' ......

[_Êý¾ÝÍÚ¾ò_] pythonʵ¼ùÖ®1

 ¼Æ»®Õâ¸öÐÇÆÚѧϰÓÃpythonʵÏÖ¾ö²ßÊ÷Ëã·¨¡£½ñÍí¾ÍÅöµ½Á˺öàÎÊÌ⣬ºÃ¾ÃûÓÐÓÃpythonÁË£¬²¢ÇÒ3.0ºÍÊé±¾ÉϵÄÓÐЩ¶«Î÷²»Ì«Ò»Ö£¬ÕâÀï¼Ç¼Ï¼¸¸öµØ·½¡£
1£© import module Èç¹û²»ÊÇÔÚ±ê׼Ŀ¼Ï£¨ÏµÍ³µÄpath£¬pythonµÄĿ¼£¬µ±Ç°Ä¿Â¼£©£¬ÄÇôÐèÒªÏÈimport sys£¬È»ºósys.path.append('')£»
2£© ¸Ä±äÔ´Îļþºó£¬ÔÙ´Îimport ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ