質問

I'm writing a program that connects to my website via ftp. If the login authentication fails, I want it to continue on to do something else. But an authentication failure error automatically exits the program. Is there a way to ignore this and continue on?

役に立ちましたか?

解決

You can use Python's Exception Handling:

try:
    do_something()
except Exception, ex:
    print "The process failed because", ex
    do_something_else()

replace do_something() with code you first want to try.. Replace do_somthing_else() code with what you wish to try when do_something() part fails

Reference for Exception Handling

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top