课程: Programming Concepts for Python

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Catch errors

Catch errors

- No matter how good of a programmer you are, you will have errors in your code and there are two main types of errors that you'll encounter, syntax errors and runtime exceptions. Syntax or parsing errors are usually the first type of problem you run into, and those are the little typos and other mistakes that make your code invalid so that it can't even be run. Unfortunately, those are pretty easy to handle. Most development tools will instantly detect syntax errors in your code and they'll let you know where there's a problem so you can go fix it. Once you have a valid program. The next worry are exceptions, and these are the problems that occur when your program is running and it tries to do something illegal, like divide by zero. Numerous issues can cause these exceptions, so it's important to incorporate error handling into your code to detect when these problems occur, and in many cases, the program can take some…

内容