python3 获取函数变量


Python 3.8可以使用f字符串调试功能  
1 test_dict = {1: "1", 2: "2", 3: "3"}
2 print(f"{test_dict=}")
3 var_name = f'{test_dict=}'.split('=')[0]
4 print(var_name)

相关