python 标准模块 string

string 模块提供了一些用于处理字符串类型的函数

案例:

#!/usr/bin/evn python
#_*_ coding:utf-8 -*-
import string

text = "Monty Python's Flying Circus"

print string.upper(text)
print string.lower(text)
print string.split(text)
print string.join(string.split(text),"+")
print string.find(text,'Python')
print string.count(text,'y')

 

结果:

MONTY PYTHON'S FLYING CIRCUS
monty python's flying circus
['Monty', "Python's", 'Flying', 'Circus']
Monty+Python's+Flying+Circus
6
3

 

posted @ 2017-09-19 19:42  Ray雷  阅读(151)  评论(0编辑  收藏  举报