Pycharm(Python IDE)只能显示列表的前300个成员

时间:2016-01-28 17:21:47

标签: python pycharm

当我填充一个包含300多个元素的列表时,我用来阅读Python的工作环境,Pycharm只显示前300个元素。这适用于社区版和专业版。有没有人知道如何解决这个问题,如果没有人知道IDE可以显示列表的所有元素,即使该列表有10,000个元素?

我想再次强调,为了调试目的,我需要能够查看列表的元素。

This shows that more than 300 elements cannot be viewed

This shows the length of the list in question.

4 个答案:

答案 0 :(得分:25)

是的,可以用pycharm显示更多项目。

查看文件helpers/pydev/_pydevd_bundle/pydevd_resolver.py

MAX_ITEMS_TO_HANDLE编辑为您需要的任何内容。

# Note: 300 is already a lot to see in the outline (after that the user should really use the shell to get things)
# and this also means we'll pass less information to the client side (which makes debugging faster).
MAX_ITEMS_TO_HANDLE = 500

更改后您不需要重新启动IDE,只需重新运行脚本即可。

对于Windows 10,可以在Program Files/JetBrains/PyCharm <version>/helpers/pydev/_pydevd_bundle/pydevd_resolver.py

找到该文件

答案 1 :(得分:9)

当我需要在调试器中检查长列表时,我使用“Evaluate expression”(或alt + F8)打印出变量。

Evaluate expression location

您将进入命令窗口。

Evaluate expression command window

然后在控制台窗口中找到您的变量。

Console

答案 2 :(得分:4)

您可以为列表的其余部分添加一个或多个监视,其中包含以下列表:

my_huge_list = '0' * 1000

然后为my_huge_list[300:]然后my_huge_list[600:]添加一个手表,依此类推。

它不是非常漂亮或方便,但确实有效。我很确定这可以以某种方式编写到pycharm中,但我目前的列表不超过450个项目,所以这次不值得。

答案 3 :(得分:1)

该问题已有几年历史了,但是它解决了一个问题,该问题在今天使用默认设置时仍然有意义。对于macOS上的PyCharm 2019.3社区版(在10.11.6上测试),解决方案与@VaclavKasal的回答略有不同。设置文件位于/Applications/PyCharm\ CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_resolver.py 例如,要显示3000个项目,而不是默认的100

更改自:

# Note: 300 is already a lot to see in the outline (after that the user should really use the shell to get things)
# and this also means we'll pass less information to the client side (which makes debugging faster).
MAX_ITEMS_TO_HANDLE = 300 if not IS_PYCHARM else 100

收件人:

# Note: 300 is already a lot to see in the outline (after that the user should really use the shell to get things)
# and this also means we'll pass less information to the client side (which makes debugging faster).
MAX_ITEMS_TO_HANDLE = 300 if not IS_PYCHARM else 3000