同一变量“args”的两个不同值

2024-10-01 02:34:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我从python脚本调用一个方法,其中一个变量是args。 一旦我进入该方法,当我试图查看变量args的值时,“print args”和执行“args”将显示两个不同的值。 有谁能告诉我这两个命令有什么区别吗。在

我希望这两个命令显示相同的值。在

(Pdb) print args
<lib.framework.testmanager.RunArgs object at 0xb26acac>

(Pdb) args
args = <lib.framework.testmanager.RunArgs object at 0xb26acac>
u = <upgradelib.UpgradeManager object at 0x946cf8c>
spec = {'excludeHosts': None, 'evacuateAllData': True, 'WaitTime': None, 'IssueType': 'Host Disconnect', 'performObjectUpgrade': True, 'downgradeFormat': False}
result = True

Tags: 方法命令脚本nonetrueobjectlibargs
1条回答
网友
1楼 · 发布于 2024-10-01 02:34:26

args是一个PDB调试器命令。使用!args显示实际变量。在

参见Debugger Commands section

a(rgs)
Print the argument list of the current function.

以及

[!]statement
Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger command.

(重点是我的)。在

在您的args输出中,您可以在第一行看到args参数值。在

就我个人而言,我发现(a)rgs命令有点毫无意义;它使用str()而不是repr()来打印所有值;这使得具有类似__str__输出值的对象之间的差异不可见(例如str与{},或者BeautifulSoup元素与HTML字符串的对比等等)。在

相关问题 更多 >