Python: Return

2019-06-19  本文已影响0人  Andy512

In the self-defined function, maybe there are many items to be returned. In this case, it will be better to return a dictionary:

The commonly used:

def my_fun()
    # some operations
    return item1, item2, item3, item4

With dict:

def my_fun()
      # some operations
      return {"item1": value1,
                  "item2": value2,
                   "item3": value3,
                   "item4": value4}
上一篇 下一篇

猜你喜欢

热点阅读