How to give the Python console in PyCharm access to the variable space of a script?(如何让 PyCharm 中的 Python 控制台访问脚本的变量空间?)
问题描述
我正在寻找一种方法,让 PyCharm 中的 Python 控制台(可从 Tools -> Run Python Console... 访问)由我目前正在使用的脚本定义.
例如,假设我的脚本(PyCharm 项目的一部分)包含以下行
aa = 4然后我想直接进入控制台并操作刚刚由脚本定义的变量,例如
<预><代码>>>>一个*28
我找不到这样做的方法,以及相关的问题
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 question Is there a Variable Explorer for PyCharm doesn'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 控制台访问脚本的变量空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何让 PyCharm 中的 Python 控制台访问脚本的变
基础教程推荐
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
