|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
while True:
temp = input('请输入一个密码:')
if temp == temp.isnumric():
print('密码中必须包括数字和字母',end='')
if temp == temp.isalpha():
print('密码中必须包括数字和字母',end='')
if temp == temp.isalnum():
print('编写成功')
为什么会报错AttributeError: 'str' object has no attribute 'isnumric'
看不懂啊。。。。。
我觉得代码没错啊
你的代码里没有退出,而且,temp==,那都是什么判断,参考下面代码:
- while True:
- temp = input('请输入一个密码:')
- if temp.isnumeric() or temp.isalpha(): #既然内容一样,就合并吧
- print('密码中必须包括数字和字母',end='')
- # if temp.isalnum(): #排除了纯数字和纯字母,为什么还要这个,符号不行吗?
- else:
- print('编写成功')
- break
复制代码 #要有退出循环的语句
|
|