how can i print return values (success/failure) from a python script
i have a python script, that connects to a web service using suds client, and gets data. Now 开发者_JAVA技巧based on what was queried, i can get a true or false as results. so when i run the script with correct data values, i get nothing on the stdout, but when i use incorrect data, i get "data error", based on :
except Exception, e: print 'data error'
Is there a way to get the values of success and failure from a python script, so in case of failure, i can notify the user. I am referring to the return values frm a failed/success python script
What you get on stdout is what you print in your script (so in your case, you will get 'data error' on stdout in case of error).
If you want to handle correctly the return code of you python script, take a look to the sys.exit(return_code) method which will return to the caller the return_code
(in general 0 when all is OK, something else when something bad happend)
精彩评论