How can I return two values from a function in Python?

前端 未结 8 826
执笔经年
执笔经年 2020-11-22 12:14

I would like to return two values from a function in two separate variables. For example:

def select_choice():
    loop = 1
    row = 0
    while loop == 1:         


        
8条回答
  •  攒了一身酷
    2020-11-22 12:24

    def test():
        ....
        return r1, r2, r3, ....
    
    >> ret_val = test()
    >> print ret_val
    (r1, r2, r3, ....)
    

    now you can do everything you like with your tuple.

提交回复
热议问题