热线电话:13121318867

登录
2019-06-25 阅读量: 504
如何使用字典返回多个值?

使用词典:词典类似于其他语言中的哈希或地图。可以

# A Python program to to return multiple

# values from a method using dictionary

# This function returns a dictionary

def fun():

d = dict();

d['str'] = "GeeksforGeeks"

d['x'] = 20

return d

# Driver code to test above method

d = fun()

print(d)

输出:

{'x':20,'str':'GeeksforGeeks'}
35.1908
1
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子