?hnlich wie bei Matlab k?nnen Sie Variablen nach Abschluss des Programms direkt auf der Konsole bedienen, anstatt ein unabh?ngiges Konsolenprogramm zu starten. Ich frage mich, ob eine Python-IDE dieses Verhalten unterstützt
Python 自帶的 IDLE 就可以做到了,你開(kāi)啟一個(gè) python file 後 run module,你會(huì)發(fā)現(xiàn)主控臺(tái)上可以操控 file 中的 variable
Pycharm 的部分我自己試了一下,你進(jìn)到 Run/Edit Configurations...
然後把 Interpreter options
加入 -i
的選項(xiàng):
之後運(yùn)行 script 完畢,shell 會(huì) keep 在那邊不會(huì)結(jié)束
其實(shí)不需要 ide 就可以做到你想做的了
假設(shè)你有一個(gè) python script test.py
a = 5
b = [1, 2, 3]
直接用:
$ python -i test.py
運(yùn)行 test.py
完畢後,Python 會(huì)停在 console 中可以繼續(xù)互動(dòng)
或是用:
$ python
開(kāi)啟 python shell 後,用 import
匯入 test 並執(zhí)行,接著你就可以操控 variable 了:
>>> from test import *
>>> a
5
>>> b
[1, 2, 3]
這也有同樣效果
我回答過(guò)的問(wèn)題: Python-QA
相對(duì)原生python shell,iPython更加好用一些,另外集成Matplotlib之后可以畫(huà)出類似matlab的圖形。