matlab - Can Python start the console while saving program variables?
phpcn_u1582
phpcn_u1582 2017-07-05 11:04:10
0
2
1498

Similar to matlab, you can directly operate variables on the console after the program is completed, instead of starting an independent console program. I wonder if any Python IDE supports this behavior

phpcn_u1582
phpcn_u1582

reply all(2)
世界只因有你

Python’s own IDLE can do this. After you open a python file and run the module, you will find that you can control the variables in the file on the main console


I tried the Pycharm part myself, you go to Run/Edit Configurations...

Then add Interpreter options to the options of -i:

After running the script, the shell will keep and will not end there


In fact, you don’t need an IDE to do what you want

Suppose you have a python script test.py

a = 5
b = [1, 2, 3]

Use directly:

$ python -i test.py

Run test.pyAfter completion, Python will stop in the console and you can continue to interact

Or use:

$ python

After opening the python shell, use import to import test and execute it. Then you can control the variable:

>>> from test import *
>>> a
5
>>> b
[1, 2, 3]

This also has the same effect


Questions I answered: Python-QA

伊谢尔伦

Compared with the native python shell, iPython is easier to use. In addition, after integrating Matplotlib, you can draw matlab-like graphics.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template