问题描述
我正在寻找一种在PyCharm中提供Python控制台的方法(可从工具-> 运行Python控制台... )访问由我当前正在使用的脚本定义的变量。
例如,说我的脚本( PyCharm项目)包含以下行
aa = 4
然后我想直接进入控制台并操作脚本刚刚定义的变量,例如
>> aa * 2
8
我找不到解决办法,相关问题
I'm looking for a way to give the Python console in PyCharm (available from Tools -> Run Python Console...) access to the variables that were defined by a script that I'm currently working with.
For instance, say that my script (part of a PyCharm project) contains the line
aa = 4
I then want to go straight to the console and manipulate the variable that was just defined by the script, e.g.
>>> aa*2 8
I can't find a way to do this, and the related questionIs there a Variable Explorer for PyCharmdoesn't help me: the accepted answer there seems to imply that the console in fact should have access to the variable space of the current workspace/script, but that isn't true in my case.
(As a side note: The above was possible in the only other IDE that I've tried other than PyCharm: PyScripter. It is also how I'm used to work in MATLAB.)
This answer works in the Pycharm Python console.Another option is to run in debug mode. You can click on the "Show Python Prompt" icon in the bottom left corner of the debug console to open a prompt to access the variable space (circled red in screenshot below Pycharm 2017.3.3 Community edition)
这篇关于如何让PyCharm中的Python控制台访问脚本的可变空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!