我想用eval函数查看变量periods_6_lend_month2020-03-01_30_的值
用eval函数的时候提示非法标识,如下:
eval("periods_6_lend_month2020-03-01_30_")
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-44-c0db317d9f3d>", line 1, in <module>
eval("periods_6_lend_month2020-03-01_30_")
File "<string>", line 1
periods_6_lend_month2020-03-01_30_
^
SyntaxError: invalid token
这是因为对eval函数的定义不清晰导致的,正确的代码应该是
global()["periods_6_lend_month2020-03-01_30_"]