码迷,mamicode.com
首页 > 编程语言 > 详细

进阶第六课 Python模块之string

时间:2018-03-30 21:47:22      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:格式化   imp   string   格式   www   输出   import   pre   模块   

对字符串做格式化操作

1、string.capwords()

把字符串中所有单词的首字母均变成大写字母。看例子:

>>> a=Tom is a boy and Kate is a girl.
>>> import string
>>> b=string.capwords(a)
>>> b
Tom Is A Boy And Kate Is A Girl.

2、Template

指定文档模板,把字符串按照指定模板的格式输出。

具体可以看这个链接的讲解:

https://www.cnblogs.com/subic/p/6552752.html

 

进阶第六课 Python模块之string

标签:格式化   imp   string   格式   www   输出   import   pre   模块   

原文地址:https://www.cnblogs.com/tuobeiwoniu/p/8678164.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!