What does Python's eval() do?

前端 未结 10 2205
后悔当初
后悔当初 2020-11-22 01:48

In the book that I am reading on Python, it keeps using the code eval(input(\'blah\'))

I read the documentation, and I understand it, but I still do no

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 02:29

    The eval function lets a Python program run Python code within itself.

    eval example (interactive shell):

    >>> x = 1
    >>> eval('x + 1')
    2
    >>> eval('x')
    1
    

提交回复
热议问题