从函数中,返回多个参数

Returning Multiple Values in Python - GeeksforGeeks

在 Python 中,我们使用 return Tuple 的方式,从函数中返回多个参数,并直接赋值给变量。

# A Python program to return multiple 
# values from a method using tuple 

# This function returns a tuple 
def fun(): 
	str = "geeksforgeeks"
	x = 20
	return str, x; # Return tuple, we could also 
					# write (str, x) 

# Driver code to test above method
str, x = fun() # Assign returned tuple 
print(str) 
print(x)

参考文献

WikiNotes/return(学习笔记)
The Python return Statement: Usage and Best Practices – Real Python