下一个函数将因某些数据而失败。在哪里用试块包装比较好?你知道吗
if attr in obj_request:
new_record = GosReestr()
new_record.display_name_department = request.user.profile_ad.department
new_record.set_data(**obj_request[attr][_main_data])
print('before')
new_record.save()
print('after')
这样更好吗?你知道吗
if attr in obj_request:
new_record = GosReestr()
new_record.display_name_department = request.user.profile_ad.department
new_record.set_data(**obj_request[attr][_main_data])
print('before')
try:
new_record.save()
except as e
print('after')
还是将所有内容都封装在一个if
块中更好?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐