2019-06-25
阅读量:
454
如何在python中使用元祖返回多个值?
使用元组:元组是以逗号分隔的项目序列。它是使用或不使用()创建的。元组是不可变的。见对元组和列表的详细信息。
# A Python program to 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)
输出:
geeksforgeeks
20






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论