Error và Exception trong Python

Errors và Exceptions Trong phần này chúng ta chỉ nói đến Syntax error và Exception Error. Trong lập trình chúng ta hay gặp phải syntax error là nhiều nhất. Syntax error là những lỗi cú pháp mà trong quá trình học tập hay gặp phải. Ví dụ: SyntaxError: invalid syntax nếu cú pháp đúng sẽ là: >>> while True: print ("Hello Thanh DevOps") Exception : Exception xuất hiện khi một tthực thi một python script nào đó. Trong phần tới chúng ta sẽ bàn thêm về handle exception trong python như thế nào nhé. >>> 10 * (1/0) Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero ZeroDivisionError : lỗi thi thực thi 1 phép tính chia cho 0 >>> 4 + spam*3 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'spam' is not defined NameError : biế