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 控制台访问脚本的变
基础教程推荐
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 筛选NumPy数组 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01