Reputation: 336
I'm using SMTP and SSH libs, it works all fine in Python 2.7, but there is a problem in Python3. examples:
try:
server.login(user, passwd)
flag = 0
except smtplib.SMTPException, err:
and
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
if timeout_sec is not None:
ssh.connect(target, username='', password='', timeout=timeout_sec)
else:
ssh.connect(target, username='', password='')
exit = 0
break
except paramiko.ssh_exception.AuthenticationException, ssherr:
the exception examples are not working. How can I fix this?
except paramiko.ssh_exception.AuthenticationException, ssherr:
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 630
Reputation: 94827
except smtplib.SMTPException as err:
except paramiko.ssh_exception.AuthenticationException as ssherr:
See the docs at https://docs.python.org/3/reference/compound_stmts.html#the-try-statement
Upvotes: 2