易截截图软件、单文件、免安装、纯绿色、仅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 time
>>> import datetime
>>>
now = time.localtime()
>>> now
(2006, 4, 30, 18, 7, 35,
6, 120, 0)
>>> type(now)
<type 'time.struct_time'>
>>>
str_now = time.strftime("%m/%d/%Y %X", now )
>>>
str_n ......

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 八荣八耻

http://www.okpython.com/bbs/thread-3367-1-2.html
以动手实践为荣 , 以只看不练为耻;
以打印日志为荣 , 以单步跟踪为耻;
以空格缩进为荣 , 以制表缩进为耻;
以单元测试为荣 , 以人工测试为耻;
以模块复用为荣 , 以复制粘贴为耻;
以多态应用为荣 , 以分支判断为耻;
以Pythonic为荣 , 以冗余拖沓为耻;
以总结分享为 ......

Python 中文字符串的截取

def
subString
(s,
length):
   
us = unicode(s, 'utf-8
')
    gs =
us.encode('gb2312
')
    n = int(length)
   
t = gs[:n]
    while True
:
        try
:
  &nb ......

UBUNTU10.04安装stackless python运行高性能服务器

以下"#"开头是Ubuntu终端命令
1。首先安装Ubuntu10.04
参考 http://wiki.ubuntu.org.cn/
2。修改root用户密码
3。使用root登陆系统
 
4。Ubuntu默认已经安装python2.6.5
 
5。下载stackless
查看网址 http://zope.stackless.com/download/sdocument_view
# cd /usr/src
# wget http://www.sta ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号