locals()

返回一个字典对象。收集并返回局部变量。
可以用在函数中,用来收集局部变量。

 

>>> def f():
...   a = 'tom'
...   print(locals())
...
>>> f()
{'a': 'tom'}

 

相关文章:

  • 2022-12-23
  • 2021-06-26
  • 2021-11-02
  • 2022-01-20
  • 2022-12-23
  • 2021-11-09
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案