【发布时间】:2015-09-25 02:51:46
【问题描述】:
例如,我有一个公开的函数,例如:
@cherrypy.expose
def create_purchase(self, price, amount, description):
price = float(price)
amount = int(amount)
descript = str(description)
有没有办法自动将价格转换为浮点数,金额为 int,并将描述转换为 str。如果其中任何一个失败,则认为这是一个错误。
【问题讨论】: