# -*- coding:UTF-8 -*-
'''
Created on 2015年10月25日
@author: young
'''
from __builtin__ import str
s='abc123abc'
print s.capitalize() #首字母大写
print s.count('ab') #统计字符串出现次数
print s.isalpha() #是否仅包含0-9A-Za—z
print s.split('123') #分割
print len(s)#字符串长度
print s[1] #访问下标为1的字符
print s[-1] #倒数第一个
print s[-0]
print s[1:-1] #第二道倒数第二个
print 's[1:1]='+ s[1:1] + 'end'#前闭后开,所以没有字符
print s[:-2] #同 s[0:-2]
#格式化字符串
print 'hello %s , I am %d years old' %('Tom',10) #格式化输出
print '%d %x' % (0XFFF,4095)
print 'num to str '+str(123)
打印
Abc123abc
2
False
['abc', 'abc']
9
b
c
a
bc123ab
s[1:1]=end
abc123a
hello Tom , I am 10 years old
4095 fff
num to str 123