开发 Tips(7)

主要记录最近遇到的一些开发问题,解决方法。

1. Python2 和 Python3 中的异常处理

Python2,Python3 都支持的两种方式:
  • 带参数

1
2
except (ExceptionType) as Argument:
    1. 访问 Argument
  • 不带参数
1
except ExceptionType:

2. Django 中的 get_object_or_404 和 get_queryset