Home>Article>Backend Development> How does Python determine that the input is all letters?

How does Python determine that the input is all letters?

silencement
silencement Original
2019-06-11 14:56:00 10125browse

How does Python determine that the input is all letters?

Strict analysis: any symbols other than numbers or letters (spaces, semicolons, etc.) will be False
isalnum() must be a mixture of numbers and letters
isalpha() is not case-sensitive

str_1 = "123" str_2 = "Abc" str_3 = "123Abc" #用isdigit函数判断是否数字 print(str_1.isdigit()) Ture print(str_2.isdigit()) False print(str_3.isdigit()) False #用isalpha判断是否字母 print(str_1.isalpha()) False print(str_2.isalpha()) Ture print(str_3.isalpha()) False #isalnum判断是否数字和字母的组合 print(str_1.isalnum()) Ture print(str_2.isalnum()) Ture print(str_1.isalnum()) Ture

Note: If the string contains characters other than letters or numbers, such as spaces, it will also return False

The above is the detailed content of How does Python determine that the input is all letters?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn