Answer the question
In order to leave comments, you need to log in
When reading, one empty line is added, which leads to an error, what should I do?
Wrote a program to work with ftp. If there is 1 line in the file, then everything is fine, but if there are 2 or more lines, then a line is read and one empty line is added to it, which leads to an error when connecting to ftp.
Program code:
user="admin"
passw="admin"
from ftplib import FTP_TLS
f = open('ip.txt')
for ip in f:
print(ip)
ftp = FTP_TLS(ip)
if "331" in ftp.sendcmd('USER '+user):
try:
ftp.sendcmd('PASS '+passw)
except:
print("530 Password or login is bad")
else:
print("230 Password is good")
ftp.ihostfull.com
ftp.djejjsjrhjsks.by
ftp.debian.org
Answer the question
In order to leave comments, you need to log in
Check if there is a line break ('\n') at the end of the line and remove it if there is one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question