- 博客(6)
- 资源 (1)
- 收藏
- 关注
原创 正则--re.search
#!/usr/bin/env python3.4#coding:utf-8import repattern = "text"text = "Dose this text match the pattern?"match = re.search(pattern, text)s = match.start()e = match.end()print("Found '%s'\nin '%
2014-12-15 20:29:48 367
原创 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 500
原创 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 647
原创 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 957
原创 python3获取天气信息
通过对http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 的调用,获取天气信息
2014-08-30 16:44:38 1278
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人