try - except 语法这个是一个用来防止系统错误的一个好方法。比如说溢出、越界之类的错误可以用这个语法来处理。我们把可能发生的错误放在 try 模块里， 用 except 来处理异常。注意，每一个 try 都必须有一个 except 。下面是一个简单的示例：#vector indexing operations on 1-D vectors a = np.arange(10) print(a) #access an element print(f"a[2].shape: {a[2].shape} a[2] = {a[2]}, Accessing an element returns a scalar") # access the last element, negative indexes count from the end print(f"a[-1] = {a[-1]}") #indexs must be within the range of the vector or they will produce and error try: c = a[10] except Exception as e: print("The error message you'll see is:") print(e)