1
我的意圖是在Google App Engine中部署Web服務。我正在使用CherryPy,因爲我發現它很容易理解。Cherry Py - 在Python中以XML形式返回輸出
import sys
sys.path.insert(0,'cherrypy.zip')
import cherrypy
from cherrypy import expose
class Converter:
@expose
def index(self):
return "Hello World!"
@expose
def fahr_to_celc(self, degrees):
temp = (float(degrees) - 32) * 5/9
return "%.01f" % temp
@expose
def celc_to_fahr(self, degrees):
temp = float(degrees) * 9/5 + 32
return "%.01f" % temp
cherrypy.quickstart(Converter())
我想知道,如何返回XML格式輸出,就像
<?xml version="1.0" encoding="UTF-8"?>
<root>
<answer>Hello World!</answer>
</root>
我在Python初學者。請幫助我。
Hariharan
非常感謝..它幫助。 – harihb 2011-03-28 15:19:57