python提示list index out of range_在python脚本上获取“IndexError:list index out-of-range”

我有下面的程序,我发现,并试图编辑,使其工作。我在python2.7中使用Kbuntu。运行脚本时出现以下错误:rm: cannot remove ‘Devices_Config_Pull.xls’: No such file or directory

rm: cannot remove ‘Devices_Config_Pull.zip’: No such file or directory

Traceback (most recent call last): File "config_pull.py", line 17,

in

connection = sys.argv[1] IndexError: list index out of rangeimport os,sys,string

sys.path.append('/home/user/python/lib/lib/python')

import pexpect

import xlwt

import credential

os.system('rm Devices_Config_Pull.xls') #This will remove previews created spreadsheet

os.system('rm Devices_Config_Pull.zip') #This will remove previews created zip

list_devices=open('list.txt').readlines() #This will read the list of devices that file is on the same location as the script

email, UID, passwd, enable = credential.cred() #This is a module that I created that will store all of credential

*connection = sys.argv[1]

connection = int(connection)*

### If the argument is 1 it will telnet into the devices if the argument is 2 it will ssh into the devices

if connection == 1:

tunnel = 'telnet '

conmess = 'telnet'

elif connection == 2:

tunnel = ('ssh -o StrictHostKeyChecking=no -l ' + UID + ' ')

conmess = 'SSH'

######## This for loop block. is the loop for telnet/ssh into the devices

wbk = xlwt.Workbook() #Create an excel workbook

font = xlwt.Font()

font.bold = True

#style = .XFStyle()

style.font = font < lines omitted>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值