Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 在Python中,我试图调用一个函数,但它对变量无效_Python 2.7_Paramiko - Fatal编程技术网

Python 2.7 在Python中,我试图调用一个函数,但它对变量无效

Python 2.7 在Python中,我试图调用一个函数,但它对变量无效,python-2.7,paramiko,Python 2.7,Paramiko,下面是函数 def lldp(客户端1): 返回 变量A将被赋值,当我调用这个函数到另一个脚本中时,如下图所示 lldp(客户1) 我正在犯错误 NameError:未定义名称“A” 尝试将内部函数定义为全局函数仍然很幸运 尝试返回一个仍然没有运气 我能弄明白 返回函数中缺少的值,脚本中缺少A=lldp() 现在工作 请修复您的缩进。退货缩进?请看问题。看起来对吗?如果没有,请修复它。查看 stdin, stdout, stderr = client1.exec_command('show ll

下面是函数

def lldp(客户端1):

返回

变量A将被赋值,当我调用这个函数到另一个脚本中时,如下图所示

lldp(客户1)

我正在犯错误

NameError:未定义名称“A”

尝试将内部函数定义为全局函数仍然很幸运
尝试返回一个仍然没有运气

我能弄明白

返回函数中缺少的值,脚本中缺少A=lldp()


现在工作

请修复您的缩进。退货缩进?请看问题。看起来对吗?如果没有,请修复它。查看
stdin, stdout, stderr = client1.exec_command('show lldp neighbor interface' + " " + q[0] + " " + '| match add')
z = stdout.read()
A = z.split()
A = A[9]
print A
if A == ':':
    sys.exit()