Python3 中的 isalpha()函数

首页 / Python3入门教程 / Python3 中的 isalpha()函数

如果字符串中的所有字符均为字母,Python的 isalpha()方法将返回true。如果字符不是字母,则返回False。它返回True或False。

isalpha - 语法

isalpha - 返回

它返回True或False。

链接:https://www.learnfk.comhttps://www.learnfk.com/python3/python-string-isalpha-method.html

来源:LearnFk无涯教程网

让无涯教程看一下isalpha()方法的一些例子,以了解其功能。

无涯教程网

# Python isalpha() method example
# 变量声明
str = "Learnfk"
# 函数调用
str2 = str.isalpha()
# 显示结果
print(str2)

输出

True
isalpha - Python String isalpha()方法示例2
# Python isalpha() method example
# 变量声明
str = "Welcome to the Learnfk"
# 函数调用
str2 = str.isalpha()
# 显示结果
print(str2)

输出

False
isalpha - Python String isalpha()方法示例3
# Python isalpha() method example
# 变量声明
str = "Learnfk"
if str.isalpha() == True:
    print("String contains alphabets")
else: print("Stringn contains other chars too.")

输出

String contains alphabets

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

微服务架构核心20讲 -〔杨波〕

持续交付36讲 -〔王潇俊〕

邱岳的产品实战 -〔邱岳〕

玩转Git三剑客 -〔苏玲〕

Netty源码剖析与实战 -〔傅健〕

OAuth 2.0实战课 -〔王新栋〕

手把手带你搭建秒杀系统 -〔佘志东〕

说透元宇宙 -〔方军〕

云原生基础架构实战课 -〔潘野〕

好记忆不如烂笔头。留下您的足迹吧 :)