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

·ÖÏíÒ»¸ö¼òµ¥µÄpythonÄ£°åÒýÇæ


#coding:utf-
8
  
__author__="sdm"
  
__author_email='sdmzhu3@gmail.com'
  
  
__date__ ="$2009-8-25 21:04:13$"
  
  
''
'  
pytpl ÀàËÆ
phpµÄÄ£°åÀà  
  
  
''
'  
import
 sys  
import
 StringIO  
import
 os.path  
import
 os  
#Ä£
°åµÄ»º´æ  
_tpl_cache={}  
class
 Pytpl:  
  
    def __init__(self,tpl_path='./'
):  
        self.tpl_path=tpl_path  
        self.data={}  
        self.output = StringIO.StringIO()  
        pass  
  
    def set(self,name,value):  
        ''
'  
        Éè
ÖÃÄ£°å±äÁ¿  
        ''
'  
        self.data[name]=value;  
        pass  
  
    def get(self,name):  
        ''
'  
        µÃ
µ½Ä£°å±äÁ¿  
        ''
'  
        t={}  
        return
 t.get(name,
''
)  
        pass  
  
    def tpl(self,tplname):  


Ïà¹ØÎĵµ£º

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'): ......

pythonÖÐÈçºÎÅжÏÒ»¸ö±äÁ¿µÄÊý¾ÝÀàÐÍ£¿(Ô­´´)

import types
type(x) is types.IntType # ÅжÏÊÇ·ñint ÀàÐÍ
type(x) is types.StringType #ÊÇ·ñstringÀàÐÍ
.........
--------------------------------------------------------
³¬¼¶¶ñÐĵÄģʽ£¬²»ÓüÇסtypes.StringType
import types
type(x) == types(1) # ......

pythonÖеÄlistÈçºÎ½øÐÐÏà¼õ²Ù×÷»òÕß½«list·ÖƬ


ÎÊÌâÃèÊö£º¼ÙÉèÎÒÓÐÕâÑùÁ½¸ölist£¬
          Ò»¸öÊÇlist1£¬list1 = [1, 2, 3, 4, 5]
          Ò»¸öÊÇlist2£¬list2 = [1, 4, 5]
          ÎÒÃÇÈçºÎµÃµ½Ò»¸öеÄlist£ ......

PythonΪÀඨÒå¡°¿½±´¹¹Ô캯Êý¡±

³õѧPython£¬Õâô×öºÃÏñÓеã2£¬´ÕºÏÄÜÓãº
class MyClass():
def __init__(self, n = 10):
self._Field = n
def __getitem__(self, range):
return MyClass(self._Field)
obj1 = MyClass()
obj2 = obj1
obj3 = obj1[:]
obj1._Field = 100
obj4 = MyClass(123)
print obj1._Field, obj2. ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ