Python3 中的 istitle()函数

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

如果字符串是带标题的字符串,Python的 istitle()方法将返回True。否则返回False。

istitle - 语法

istitle()

istitle - 返回

它返回True或False。

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

无涯教程网

# Python istitle() method example
# 变量声明
str = "Welcome To Learnfk"
# 函数调用
str2 = str.istitle()
# 显示结果
print(str2)
istitle - Python字符串istitle()方法示例2
# Python istitle() method example
# 变量声明
str = "Welcome To Learnfk" # True
# 函数调用
str2 = str.istitle()
# 显示结果
print(str2)
str = "hello learnfk"    # False
str2 = str.istitle()
print(str2)

输出

True
False
istitle - Python字符串istitle()方法示例3
# Python istitle() method example
# 变量声明
str = "ab cd ef"
if str.istitle() == True:
    print("In title case")
else:
    print("Not in tit0le case")
str = "Ab Cd Ef"
if str.istitle() == True:
    print("In title case")
else:
    print("Not in title case")
str = "1b 2d 3f"
if str.istitle() == True:
    print("In title case")
else:
    print("Not in title case")

输出

Not in title case
In title case
Not in title case

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

技术教程推荐

机器学习40讲 -〔王天一〕

深入拆解Java虚拟机 -〔郑雨迪〕

A/B测试从0到1 -〔张博伟〕

Python自动化办公实战课 -〔尹会生〕

如何成为学习高手 -〔高冷冷〕

玩转Vue 3全家桶 -〔大圣〕

计算机基础实战课 -〔彭东〕

云原生架构与GitOps实战 -〔王炜〕

快速上手C++数据结构与算法 -〔王健伟〕

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