The example in this article describes the function return value usage of Python. Share to everyone for your reference. The specific analysis is as follows:
Recently learn some of the basic usage of Python, see the definition function, found that it seems to return only a return value, think of the MATLAB return multiple return value more convenient Ah, on-line check, see there is a way to return multiple values.
The return value of a Python function has two forms:
1 returns a value.
2 returns multiple values.
Now take a look at the return value of the bar.
def firstvalue (b): c = a + B return cprint firstvalue (#结果): 3
And look at the return of multiple values: How can I return multiple values, other languages generally call the function, you can only return a value, maybe I am not familiar with all the language, I know the language can only return a value, and Python can return multiple values, it is very convenient to send code to look at:
def secondvalue (b): c = a + B return (a,b,c) x, y, z = secondvalue (in) print ' ×: ', X, ' y: ', y, ' z: ', Z
Hopefully this article will help you with Python programming.