matlab - Can Python start the console while saving program variables?
phpcn_u15822017-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
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:
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
Use directly:
Run
test.py
After completion, Python will stop in the console and you can continue to interactOr use:
After opening the python shell, use
import
to import test and execute it. Then you can control the variable: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.