![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python3
z蜗牛
这个作者很懒,什么都没留下…
展开
-
string.capwords()--将字符串中所有单词的首字母大写
>>> import string>>> s = 'The quick brown fox jumped over the lazy dog.'>>> print(s)The quick brown fox jumped over the lazy dog.>>> print(string.capwords(s))The Quick Brown Fox Jumped Over The L原创 2014-11-29 15:06:06 · 949 阅读 · 0 评论 -
str.maketrans()/str.translate()--创建转换表,将一组字符转换为另一组字符
>>> s'The quick brown fox jumped over the lazy dog.'>>> leet = s.maketrans('abegiloprstz', '463611092572')>>> print(s.translate(leet))Th3 qu1ck 620wn f0x jum93d 0v32 7h3 142y d06.>>>原创 2014-11-29 15:17:13 · 641 阅读 · 0 评论 -
string.Template--字符串模板
使用模板进行操作>>> import string>>> values = {'var':'foo'}>>> t = string.Template("""... Variable : $var... Escape : $$... Variable in text: ${var}iable... """)>>> print('TEMPLATE:',原创 2014-11-29 15:25:59 · 486 阅读 · 0 评论