[英]Return more than one value using Python - Ladon functions
You can return more values by wrapping them into a list inside a class that you use as the returntype in the decorator ladonize
. 您可以通过将它们包装到用作装饰器
ladonize
中的ladonize
的类内的列表中来返回更多值。
Based on an example in the documentation for ladon: 基于ladon 文档中的示例:
from ladon.ladonizer import ladonize
from ladon.types.ladontype import LadonType
class Response(LadonType):
values = [int]
class MyService(object):
@ladonize(int, int, rtype=Response)
def foo(self, a, b):
result = Response()
result.values = [a+b, a*b]
return result
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.