小编the*_*100的帖子

Python检查输入中是否包含数字?

我正在尝试查看如何查看用户输入的数字。我尝试使用,.isdigit()但仅在数量上有效。即时通讯试图将其添加到密码检查器。我也尝试过,.isalpha()但是没有用。我做错了什么,我需要添加或更改什么?

这是我所拥有的

   password = input('Please type a password ')
   str = password
   if str.isdigit() == True:

    print('password has a number and letters!')
    else:
            print('You must include a number!')`
Run Code Online (Sandbox Code Playgroud)

python string numbers input python-3.4

3
推荐指数
1
解决办法
2495
查看次数

标签 统计

input ×1

numbers ×1

python ×1

python-3.4 ×1

string ×1