简体   繁体   English

使用Python返回多个值-Ladon函数

[英]Return more than one value using Python - Ladon functions

我们如何使用Python- Ladon函数返回多个值?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM