<legend id='M6gq8'><style id='M6gq8'><dir id='M6gq8'><q id='M6gq8'></q></dir></style></legend>
  • <tfoot id='M6gq8'></tfoot>
  • <small id='M6gq8'></small><noframes id='M6gq8'>

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

      1. 如何检查字符串是否仅包含 Python 中的字母?

        时间:2023-08-29

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

                • <bdo id='FRdxn'></bdo><ul id='FRdxn'></ul>
                    <tbody id='FRdxn'></tbody>

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

                  <tfoot id='FRdxn'></tfoot>
                  本文介绍了如何检查字符串是否仅包含 Python 中的字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试检查一个字符串是否只包含字母,而不是数字或符号.

                  I'm trying to check if a string only contains letters, not digits or symbols.

                  例如:

                  >>> only_letters("hello")
                  True
                  >>> only_letters("he7lo")
                  False
                  

                  推荐答案

                  简单:

                  if string.isalpha():
                      print("It's all letters")
                  

                  str.isalpha() 只为真如果字符串中的所有个字符都是字母:

                  如果字符串中的所有字符都是字母并且至少有一个字符,则返回 true,否则返回 false.

                  Return true if all characters in the string are alphabetic and there is at least one character, false otherwise.

                  演示:

                  >>> 'hello'.isalpha()
                  True
                  >>> '42hello'.isalpha()
                  False
                  >>> 'hel lo'.isalpha()
                  False
                  

                  这篇关于如何检查字符串是否仅包含 Python 中的字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Pandas 根据布尔条件选择行和列 下一篇:Python中的条件语句

                  相关文章

                  <legend id='L5s1i'><style id='L5s1i'><dir id='L5s1i'><q id='L5s1i'></q></dir></style></legend>
                    <bdo id='L5s1i'></bdo><ul id='L5s1i'></ul>

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

                  <tfoot id='L5s1i'></tfoot>

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