how to input python code in run time and execute it?

后端 未结 3 1418
一个人的身影
一个人的身影 2021-01-17 06:52

Well i want to input a python function as an input in run time and execute that part of code \'n\' no of times. For example using tkinter i create a textbox where the user w

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-17 07:10

    That's what execfile() is for.

    http://docs.python.org/library/functions.html#execfile

    1. Create a temporary file.

    2. Write the content of the textbox into the file.

    3. Close.

    4. Execfile.

    5. Delete when done.

提交回复
热议问题