Python中title()方法的使用简介

yipeiwu_com7年前Python基础

 title()方法返回所有单词的第一个字符大写的字符串的一个副本。
语法

以下是title()方法的语法:

str.title();

参数

  •     NA

返回值

此方法返回其中所有单词的前几个字符都是大写的字符串的一个副本。
例子

下面的例子显示了title()方法的使用。

#!/usr/bin/python

str = "this is string example....wow!!!";
print str.title();

当我们运行上面的程序,它会产生以下结果:

This Is String Example....Wow!!!

相关文章

python生成以及打开json、csv和txt文件的实例

生成txt文件: mesg = "hello world" with open("test.txt", "w") as f: f.write("{}".format(mesg))...

在自动化中用python实现键盘操作的方法详解

原来在robotframework中使用press key方法进行键盘的操作,但是该方法需要写被操作对象的locator,不是很方便,现在找到了一种win32api库写键盘操作的一个方法...

Python绘制三角函数图(sin\cos\tan)并标注特定范围的例子

Python绘制三角函数图(sin\cos\tan)并标注特定范围的例子

根据我们指定的条件检索函数中的元素 import matplotlib.pyplot as plt import numpy as np a = np.linspace(0, 2...

在Python中预先初始化列表内容和长度的实现

如果想设置相同的初值和想要的长度 >>> a=[None]*4 >>> print(a) [None, None, None, None] 如果...

selenium+python自动化测试之使用webdriver操作浏览器的方法

WebDriver简介 selenium从2.0开始集成了webdriver的API,提供了更简单,更简洁的编程接口。selenium webdriver的目标是提供一个设计良好的面向对...