【已解决】初学python,请教变量引用问题
本帖最后由 redhatuser 于 2014-12-22 20:36 编辑for r in resJ['Reservations']:
for I in r['Instances']:
if 'PrivateIpAddress' not in I:
continue
else:
iid = I['InstanceId']
iip = I['PrivateIpAddress']
if iip == eth0:
oid = iid
hosts = {}
for ip in open('/home/ec2-user/hosts'):
v = ip.split()
if len(v) == 2 and v == eth0:
return v
后面想引用oid和hname,应该怎么做喔?
我后面直接引用这两个变量名然后使用python xxx.py是可用得到正确的取值的,但是使用crontab时候就会有如下报错信息
Traceback (most recent call last):
NameError: name 'oid' is not defined
原因:
是因为前面使用python调用shell命令时候没有写全命令路径
各位大神,指点一下。。到底是什么问题啊? 说明在crontab执行的时候,没能运行到oid = iid这个语句,自己检查一下
页:
[1]