How do I execute a string containing Python code in Python?

后端 未结 14 2654
一向
一向 2020-11-22 02:42

How do I execute a string containing Python code in Python?

14条回答
  •  执笔经年
    2020-11-22 03:06

    The most logical solution would be to use the built-in eval() function .Another solution is to write that string to a temporary python file and execute it.

提交回复
热议问题