locals() 函数会以字典类型返回当前位置的全部局部变量 >>>def runoob(arg): # 两个局部变量:arg、z... z = 1... print (locals())... >>> runoob(4){'z': 1, 'arg': 4} # 返回一个名字/值对的字典