login.txt
# Contenido del fichero login.txt
- ['10.0.0.3','Root','*****','/usr/amat','C:\Users\becario2adm','yyyymmdd']
- ['10.0.0.4','Administrador','*******','/zzz','C:\Users\becario2adm','yyyy_mm_dd']
- ['10.0.0.5','Administrador','*******','/','C:\Users\becario2adm','yyyy_mm_dd']
testFtp.py
import yaml
with open("login.txt") as f:
data = yaml.safe_load(f)
for elemento in data:
print(elemento[0], elemento[1],elemento[2], elemento[3],elemento[4], elemento[5])
from ftplib import FTP
funcion ftp()
ftp = FTP(dirServer)
ftp.login(user=usuario, passwd=passwd)
How can I do so that every line I read from login.txt takes the element 0 of the array and stores it in a dirServer variable, the element [1] stores it in a user variable, and the element [2]?
So on and use those variables to make as many Ftp connections as there are lines in login.txt