Python - Readfile and SSH



我现在有这个代码来读取.CSV文件,并通过SSH将主机名/IP列在.CSV 上的路由器中

问题是该文件将该行读取为"0";192.168.2.1/r/n";示例:("节点",4,"…正在检查IP地址…","CPE-SIBFOPASO-103179-01\r\n"(

你能帮忙吗?

代码示例:

nodenum=1
f=open('Routers.csv', 'r') #Ficheiro com Hostnames
c=f.readlines()
with open('Output.csv','wb') as f: #Ficheiro novo com o output
write = csv.writer(f)
write.writerow(['Hostname', "Cellular"])
for i in c :
print ("Node", nodenum, "...Checking IP Address...", i)
try:
Connection = netmiko.ConnectHandler(ip=i, device_type="cisco_ios" , username="y", password="x", verbose=Fal

se(

通过将代码更改为,最终实现了我想要的结果

f=open('Routers.csv', 'r') 
c=f.read()
file_as_list = c.splitlines()

最新更新