描述:
Python title() 方法返回"标题化"的字符串,就是说所有单词都是以大写开始,其余字母均为小写(见 istitle())。
语法:
title()方法语法:
str.title();
参数
NA。
返回值:
返回"标题化"的字符串,就是说所有单词都是以大写开始。
实例:
def full_name(first_name, last_name):
# 带有返回值的函数
person = first_name + ' ' + last_name
return person.title()
name = full_name('nelson', 'lam')
welcome_python(name)
返回的值为: 你好,Nelson Lam,欢迎
def full_name(first_name, last_name):
# 带有返回值的函数
person = first_name + ' ' + last_name
return person
name = full_name('nelson', 'lam')
welcome_python(name)
返回的值为: 你好,nelson lam,欢迎
str = "this is string example....wow!!!";
print str.title();
以上实例输出结果如下:
This Is String Example....Wow!!!