Python dict 存放函数

  • Python 字典,能够直接存放函数,并执行正常。

#!/usr/bin/python3

dict1 = dict()


def test_fun():
    print("test dict")


dict1["func"] = test_fun


dict1["func"]()
相关文章
相关标签/搜索