`
shrek
  • 浏览: 72246 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
qja
社区版块
存档分类
最新评论

python的cheetah小例子

阅读更多
从python in a nutshell 中摘抄小例子.
import Cheetah.Template
import os, time, socket

tt = Cheetah.Template.Template('''
<html><head><title>Report by $USER</title></head><body>
<h1>Report on host data</h1>
<p>Report written at $asctime:<br/>
#for $hostline in $uname
  $hostline<br/>
#end for
</p></body></html>
''', searchList=[time, os.environ])

try: 
    tt.uname = os.uname
except AttributeError:
    tt.uname = [socket.gethostname(  )]

print tt
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics