<tfoot id='Db43Y'></tfoot>

  1. <legend id='Db43Y'><style id='Db43Y'><dir id='Db43Y'><q id='Db43Y'></q></dir></style></legend>

    <i id='Db43Y'><tr id='Db43Y'><dt id='Db43Y'><q id='Db43Y'><span id='Db43Y'><b id='Db43Y'><form id='Db43Y'><ins id='Db43Y'></ins><ul id='Db43Y'></ul><sub id='Db43Y'></sub></form><legend id='Db43Y'></legend><bdo id='Db43Y'><pre id='Db43Y'><center id='Db43Y'></center></pre></bdo></b><th id='Db43Y'></th></span></q></dt></tr></i><div id='Db43Y'><tfoot id='Db43Y'></tfoot><dl id='Db43Y'><fieldset id='Db43Y'></fieldset></dl></div>
    • <bdo id='Db43Y'></bdo><ul id='Db43Y'></ul>

    <small id='Db43Y'></small><noframes id='Db43Y'>

      验证密码 - Python

      Validation of a Password - Python(验证密码 - Python)

      <legend id='txBCW'><style id='txBCW'><dir id='txBCW'><q id='txBCW'></q></dir></style></legend>
        <tbody id='txBCW'></tbody>
    1. <tfoot id='txBCW'></tfoot>

          1. <i id='txBCW'><tr id='txBCW'><dt id='txBCW'><q id='txBCW'><span id='txBCW'><b id='txBCW'><form id='txBCW'><ins id='txBCW'></ins><ul id='txBCW'></ul><sub id='txBCW'></sub></form><legend id='txBCW'></legend><bdo id='txBCW'><pre id='txBCW'><center id='txBCW'></center></pre></bdo></b><th id='txBCW'></th></span></q></dt></tr></i><div id='txBCW'><tfoot id='txBCW'></tfoot><dl id='txBCW'><fieldset id='txBCW'></fieldset></dl></div>
              <bdo id='txBCW'></bdo><ul id='txBCW'></ul>

              <small id='txBCW'></small><noframes id='txBCW'>

                本文介绍了验证密码 - Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                所以我必须创建验证密码是否的代码:

                So I have to create code that validate whether a password:

                • 长度至少为 8 个字符
                • 至少包含 1 个数字
                • 至少包含 1 个大写字母

                代码如下:

                def validate():
                    while True:
                        password = input("Enter a password: ")
                        if len(password) < 8:
                            print("Make sure your password is at lest 8 letters")
                        elif not password.isdigit():
                            print("Make sure your password has a number in it")
                        elif not password.isupper(): 
                            print("Make sure your password has a capital letter in it")
                        else:
                            print("Your password seems fine")
                            break
                
                validate()
                

                我不确定出了什么问题,但是当我输入一个带有数字的密码时 - 它一直告诉我我需要一个带有数字的密码.有什么解决办法吗?

                I'm not sure what is wrong, but when I enter a password that has a number - it keeps telling me that I need a password with a number in it. Any solutions?

                推荐答案

                您可以使用 re 模块进行正则表达式.

                You can use re module for regular expressions.

                使用它,您的代码将如下所示:

                With it your code would look like this:

                import re
                
                def validate():
                    while True:
                        password = raw_input("Enter a password: ")
                        if len(password) < 8:
                            print("Make sure your password is at lest 8 letters")
                        elif re.search('[0-9]',password) is None:
                            print("Make sure your password has a number in it")
                        elif re.search('[A-Z]',password) is None: 
                            print("Make sure your password has a capital letter in it")
                        else:
                            print("Your password seems fine")
                            break
                
                validate()
                

                这篇关于验证密码 - Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                <tfoot id='yYenq'></tfoot>

                <small id='yYenq'></small><noframes id='yYenq'>

              • <i id='yYenq'><tr id='yYenq'><dt id='yYenq'><q id='yYenq'><span id='yYenq'><b id='yYenq'><form id='yYenq'><ins id='yYenq'></ins><ul id='yYenq'></ul><sub id='yYenq'></sub></form><legend id='yYenq'></legend><bdo id='yYenq'><pre id='yYenq'><center id='yYenq'></center></pre></bdo></b><th id='yYenq'></th></span></q></dt></tr></i><div id='yYenq'><tfoot id='yYenq'></tfoot><dl id='yYenq'><fieldset id='yYenq'></fieldset></dl></div>
                  <bdo id='yYenq'></bdo><ul id='yYenq'></ul>
                • <legend id='yYenq'><style id='yYenq'><dir id='yYenq'><q id='yYenq'></q></dir></style></legend>

                      <tbody id='yYenq'></tbody>