def input_passwd():
    pwd = input("请输入密码：")
    if len(pwd) >= 8:
        return pwd
    ex = Exception("密码长度不够8位")
    raise ex  # 主动抛出实例化的异常


# 处理异常 接收主动抛出的异常
try:
    print(input_passwd())
except Exception as result:
    print(result)

645ec57688c2c8d76d0da12cbc809ca5adc6b4ab
<mask token>

def input_passwd():
    pwd = input('请输入密码：')
    if len(pwd) >= 8:
        return pwd
    ex = Exception('密码长度不够8位')
    raise ex


<mask token>

def input_passwd():
    pwd = input('请输入密码：')
    if len(pwd) >= 8:
        return pwd
    ex = Exception('密码长度不够8位')
    raise ex


try:
    print(input_passwd())
except Exception as result:
    print(result)

def input_passwd():
    pwd = input("请输入密码：")
    if len(pwd) >= 8:
        return pwd
    ex = Exception("密码长度不够8位")
    raise ex  # 主动抛出实例化的异常


# 处理异常 接收主动抛出的异常
try:
    print(input_passwd())
except Exception as result:
    print(result)
