Can Python function return multiple data?
fl
rxjwg98 at gmail.com
Sat Jun 6 13:57:08 EDT 2015
On Saturday, June 6, 2015 at 9:39:19 AM UTC-7, Amir Arsalan wrote:
> you can use yield structure in python for multiple return. ex:
>
>
> def func(a):
> yield a*2
> print "a*2"
> yield a*3
> print "a*3"
> ...
>
>
> data = func(5) --> data = (10,15,... )
>
>
> On Wed, Jun 3, 2015 at 1:57 AM, fl <rxj... at gmail.com> wrote:
> Hi,
>
>
>
> I just see the tutorial says Python can return value in function, it does
>
> not say multiple data results return situation. In C, it is possible.
>
> How about Python on a multiple data return requirement?
>
>
>
>
>
> Thanks,
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
Excuse me. I input the following according to your idea, but I do not
understand how to use it from the echo. It does not show how to use
the multiple output results. I am a new Python user. Please give a little
more explanation if you could.
Thanks,
>>> def func(a):
yield a*2
print "a*2"
yield a*3
print "a*3"
>>> data=func(5)
>>> data
<generator object func at 0x02B97260>
>>> list(data)
a*2
a*3
[10, 15]
More information about the Python-list
mailing list