如何在python中为sftp.get传递参数
我得到了这个的输出。但是,当我试图获取以下代码行的输出时如何在python中为sftp.get传递参数,python,parameter-passing,paramiko,pysftp,Python,Parameter Passing,Paramiko,Pysftp,我得到了这个的输出。但是,当我试图获取以下代码行的输出时 a = raw_input("Select your project: ") stdin, stdout, stderr = ssh.exec_command('cd test \n cd software \n cd {0} \n ls'.format(a)) softwares = stdout.readlines() 我的击球错误如下: 回溯(最近一次调用last):文件“D:\Python脚本” 编写testcase\Param
a = raw_input("Select your project: ")
stdin, stdout, stderr = ssh.exec_command('cd test \n cd software \n cd {0} \n ls'.format(a))
softwares = stdout.readlines()
我的击球错误如下:
回溯(最近一次调用last):文件“D:\Python脚本”
编写testcase\Paramiko.py“,第32行,在
sftp.get({1}/{2}.format(pwd1,b),{2}.format(b))索引器:元组索引超出范围
我需要如何在那里传递参数,因为路径将因不同的选择而更改。格式字符串中的数字应该从0开始,而不是从1开始
stdin, stdout, stderr = ssh.exec_command('cd test \n cd software \n cd {0} \n pwd'.format(a))
pwd = stdout.readlines()
pwd1 = '\n'.join(pwd)
print pwd1
b = raw_input("Select the software you want to download: ")
sftp = ssh.open_sftp()
sftp.get('{1}/{2}'.format(pwd1,b),'{2}'.format(b))
格式字符串中的数字应从0开始,而不是从1开始
stdin, stdout, stderr = ssh.exec_command('cd test \n cd software \n cd {0} \n pwd'.format(a))
pwd = stdout.readlines()
pwd1 = '\n'.join(pwd)
print pwd1
b = raw_input("Select the software you want to download: ")
sftp = ssh.open_sftp()
sftp.get('{1}/{2}'.format(pwd1,b),'{2}'.format(b))
“{2}”。格式(b)
您告诉format插入第二个参数,但只提供一个。更改为{1}
“{2}”。格式(b)
您告诉format插入第二个参数,但只提供一个。更改为{1}
sftp.get('{}/{}'.format(pwd1, b), b)