Python下划线变量
在交互式python中,有一个“continuation变量”,即下划线Python下划线变量,python,variables,Python,Variables,在交互式python中,有一个“continuation变量”,即下划线 >>> import netlib >>> netdev = netlib.netface('eth1') >>> if netdev.getIP(): ... print _ ... 10.80.22.100 >>> 但在脚本中使用此选项时,它是未定义的,因此此操作失败: if netdev.getIP(): SetValue('ipadd
>>> import netlib
>>> netdev = netlib.netface('eth1')
>>> if netdev.getIP():
... print _
...
10.80.22.100
>>>
但在脚本中使用此选项时,它是未定义的,因此此操作失败:
if netdev.getIP(): SetValue('ipaddress', _)
是否有类似的方法或方法可以为脚本启用此功能?否。它仅在Python REPL中可用。Bummer!我想,我只是希望有一个干净的工作环境或其他选择。谢谢:)“清洁工作环境”?这不是赋值语句吗?我必须设置很多值-我只是希望将每个函数保持在一行-而不使其过长或难以阅读。我想出了一个清晰的方法来写它。谢谢=)