相关疑难解决方法(0)

如何在Python中重用多个函数的异常处理代码?

如何在Python中重用多个函数的异常处理代码?

我正在开发一个将使用Stripe Python库的项目. https://stripe.com/docs/api/python#errors

这是他们的文档中的一些示例代码.

try:
  # Use Stripe's bindings...
  pass
except stripe.error.CardError, e:
  # Since it's a decline, stripe.error.CardError will be caught
  body = e.json_body
  err  = body['error']

  print "Status is: %s" % e.http_status
  print "Type is: %s" % err['type']
  print "Code is: %s" % err['code']
  # param is '' in this case
  print "Param is: %s" % err['param']
  print "Message is: %s" % err['message']
except stripe.error.InvalidRequestError, e:
  # Invalid parameters were supplied to Stripe's API
  pass
except stripe.error.AuthenticationError, …
Run Code Online (Sandbox Code Playgroud)

python exception-handling exception function flask

13
推荐指数
1
解决办法
1743
查看次数

标签 统计

exception ×1

exception-handling ×1

flask ×1

function ×1

python ×1