locals()
返回一个字典对象。收集并返回局部变量。可以用在函数中,用来收集局部变量。
>>> def f(): ... a = 'tom' ... print(locals()) ... >>> f() {'a': 'tom'}
Powered by: 博客园 Copyright © 2025 开飞机的贝塔 Powered by .NET 9.0 on Kubernetes