Eclipse 调试中的变量查看器会截断字符串值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3199611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:52:24  来源:igfitidea点击:

Variables viewer on Eclipse debugging truncates the string values

pythoneclipsevariablesdebugging

提问by FerranB

I'm debugging Python code and when I try to show the contents of an string variable its showed truncated...

我正在调试 Python 代码,当我尝试显示字符串变量的内容时,它被截断了......

How can show the full contents of a variable debugging Python code with PyDev on Eclipse?

如何在 Eclipse 上使用 PyDev 显示变量调试 Python 代码的全部内容?

回答by AdmiralNemo

If you right-click on the details pane in either the "Variables" view or the "Expressions" view, there is a Max Length...menu option. You can enter a number there to configure the truncation of string output. Keep in mind that the calculated length includes the type identifier at the beginning, so str: 12345is actually 10 characters, not 5.

如果在“变量”视图或“表达式”视图中右键单击详细信息窗格,则会出现一个Max Length...菜单选项。您可以在那里输入一个数字来配置字符串输出的截断。请记住,计算出的长度包括开头的类型标识符,因此str: 12345实际上是 10 个字符,而不是 5 个。

There seems to be a hard limit of 1000 characters, even when entering 0, which the field description claims means "unlimited," so no matter what you put in, you will never see more than 1000 characters. I don't know if that's a known issue or not; I have not looked into it. For strings or other variables longer than this, I generally use the loggingmodule from the standard library and send the string to a log file or stderr.

似乎有 1000 个字符的硬限制,即使在输入 时0,字段描述声称这意味着“无限制”,因此无论您输入什么,您都不会看到超过 1000 个字符。我不知道这是否是一个已知问题;我没有研究过。对于比这更长的字符串或其他变量,我通常使用logging标准库中的模块并将字符串发送到日志文件或 stderr。

回答by dim

Use interactive commands for printing your big variables and don't rely on variables view. Check how to do it at aptana pydev debug console.

使用交互式命令打印大变量,不要依赖变量视图。检查如何在aptana pydev 调试控制台中执行此操作

回答by Alex Okrushko

Found the way around!

找到路了!

At the breakpoint start PyDev Debug Consoleenter image description hereenter image description here

在断点处启动PyDev Debug Console在此处输入图片说明在此处输入图片说明

and then use python interpreter to get the value

然后使用python解释器获取值

回答by Paul D'Ambra

As this was the top hit on Google I should add that if you right-click on the variables pane in debug mode and select 'copy variables' the string value that Eclipse is truncating (along with all other variables) is added in fullto the system clipboard.

由于这是 Google 上的热门话题,我应该补充一点,如果您在调试模式下右键单击变量窗格并选择“复制变量”,则 Eclipse 截断的字符串值(以及所有其他变量)将完整添加到系统剪贴板。

you can then paste it into your favourite text editor to extract the targeted value

然后您可以将其粘贴到您喜欢的文本编辑器中以提取目标值