本文主要是介绍定义input_password函数,提示用户输入密码.如果用户输入长度<8,抛出异常,如果用户输入长度>=8,返回输入的密码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
def input_password(password):str1=passwordlen1=len(str1)try:if len1<8:raise ValueError("密码长度不能小于8")else:return print(f"你的密码为:{password},请确认")except ValueError as e:print(f":Error is {e}")number1=input("请输入你的密码:") input_password(number1)
这篇关于定义input_password函数,提示用户输入密码.如果用户输入长度<8,抛出异常,如果用户输入长度>=8,返回输入的密码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!