1、PHP拋錯php
// 正確的拋出異常python
try {
if (file_exists('test_try_catch.php')) { require ('test_try_catch.php'); } else { throw new Exception('file is not exists');//throw扔出去,catch會抓到錯誤信息 } } catch (Exception $e) { echo $e->getMessage(); }
2、python拋錯ui
try: result = data.query('(name=="&")and(age>=20)') print(result) except Exception as e://這行不動,原樣寫
print('Error:', e)
沒有報錯的時候輸出: spa
id name age
4 5 & 20
報錯的時候輸出:code
Error: invalid syntax (<unknown>, line 1)