python str.title( )和str.istitle( )
2016-05-21 20:08
239 查看
本文介绍python中字符串的两个内建函数,str.title( )和str.istitle( )
>>> help(str.title)
Help on method_descriptor:
title(...)
S.title() -> string
Return a titlecased version of S, i.e.
words start with uppercase
characters, all remaining cased characters have lowercase.
>>> 'love python!'.title()
'Love Python!'
>>> 'a strange dog'.title()
'A Strange Dog'
>>> help(str.istitle)
Help on method_descriptor:
istitle(...)
S.istitle() -> bool
Return True if S is a titlecased string and there is at least one
character in S, i.e. uppercase characters may only follow uncased
characters and lowercase characters only cased ones. Return False
otherwise.
>>> ''.istitle()
False
>>> 'Love python!'.istitle()
False
>>> 'Love Python!'.istitle()
True
(完)
>>> help(str.title)
Help on method_descriptor:
title(...)
S.title() -> string
Return a titlecased version of S, i.e.
words start with uppercase
characters, all remaining cased characters have lowercase.
>>> 'love python!'.title()
'Love Python!'
>>> 'a strange dog'.title()
'A Strange Dog'
>>> help(str.istitle)
Help on method_descriptor:
istitle(...)
S.istitle() -> bool
Return True if S is a titlecased string and there is at least one
character in S, i.e. uppercase characters may only follow uncased
characters and lowercase characters only cased ones. Return False
otherwise.
>>> ''.istitle()
False
>>> 'Love python!'.istitle()
False
>>> 'Love Python!'.istitle()
True
(完)
相关文章推荐
- Python函数式编程之闭包
- python--文件操作之遍历目录
- python字符串内建函数str.index()和str.rindex()
- Python学习笔记--生成器
- Python读取JSON数据,并解决字符集不匹配问题
- Python读取JSON数据,并解决字符集不匹配问题
- python EndUpdateResource问题
- LAN中访问其它主机的jupyter/ipython
- python核心编程
- Python图表绘制:matplotlib绘图库入门/python之import机制详解
- 基于正则表达式(python)对东方财富网上证指数吧爬虫实例
- python实现socket上传下载文件-进度条显示
- python实现socket上传下载文件-进度条显示
- python 爬虫抓取19楼租房信息
- Python函数式编程之高阶函数
- python中的if __name__=='__main__'的作用
- Python输出json时中文处理问题
- Python:Python基础(三)
- 结巴中文分词使用学习(python)
- LeetCode Linked List Cycle II