如果字符串是带标题的字符串,Python的 istitle()方法将返回True。否则返回False。
istitle()
它返回True或False。
让无涯教程看看istitle()方法的一些示例,以了解其功能。
# Python istitle() method example # 变量声明 str = "Welcome To Learnfk" # 函数调用 str2 = str.istitle() # 显示结果 print(str2)
# 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
# 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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)