Python3 中的 istitle()函数

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

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

istitle - 语法

istitle()

istitle - 返回

它返回True或False。

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

来源:LearnFk无涯教程网

让无涯教程看看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

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

技术教程推荐

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

数据分析实战45讲 -〔陈旸〕

软件工程之美 -〔宝玉〕

iOS开发高手课 -〔戴铭〕

从0开发一款iOS App -〔朱德权〕

全栈工程师修炼指南 -〔熊燚(四火)〕

架构实战案例解析 -〔王庆友〕

体验设计案例课 -〔炒炒〕

AI 应用实战课 -〔黄佳〕

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