---
title: "python的cheetah小例子"
author: "shrek"
date: "2009-03-01T21:24:56Z"
tags: ["Java", "OS", "Python", "Socket"]
slug: "python-cheetah"
draft: false
lastmod: "2009-03-01T21:25:23Z"
id: 341184
url: "https://shrek.iteye.com/blog/341184"
---

从python in a nutshell 中摘抄小例子. \[code="java"] import Cheetah.Template import os, time, socket tt = Cheetah.Template.Template(''' Report by $USER

# Report on host data

Report written at $asctime:  
#for $hostline in $uname $hostline  
#end for

''', searchList=\[time, os.environ]) try: tt.uname = os.uname except AttributeError: tt.uname = \[socket.gethostname( )] print tt \[/code]