What is the significance of python3 about the circumstances in which as is used?

python3
win10
spyder

def temp_convert(var):
    try:
        return int(var)
    except ValueError as Argument:    
        print("The argument does not contain number\n",Argument)
    

temp_convert("xyz")

want to know why except ValueError as Argument: why use as to connect, and under what circumstances do you need to use as? (because it was used directly in the original tutorial, connecting ValueError,Argument: error indicates that Argument is not defined)

May.07,2022

as is the variable after the exception object is assigned to as

The reason for

"error prompt Argument not defined" is that except ValueError is no longer allowed in Python3 , and Argument can only be written in except ValueError as Argument

.

teach people to fish is better than teach people to fish python.org/3/reference/compound_stmts.html-sharpthe-try-statement" rel=" nofollow noreferrer "> https://docs.python.org/3/ref...

Menu