参考:http://yuoveyu.blog.51cto.com/2926448/597529
#!/usr/bin/python
# -*- coding: utf-8 -*-
_str="Hello,World"
#1.获取字符串的第一个字母
print "1.获取字符串的第一个字母:"+_str[0]
#2.获取字符串的第二和第三个字母
print "2.获取字符串的第二和第三个字母:"+_str[1:3]
#3.获取字符串的最后一个字母
print "3.获取字符串的最后一个字母:"+_str[-1]
#4.字符串开头字母判断
if _str.startswith('Hello'):
print "4.字符串开头字母比较:以Hello开头"
#5.字符串结尾字母判断
if _str.endswith('World'):
print "5.字符串结尾字母比较:以World结尾"
#6.获取字符串长度
print "6.获取字符串长度:"+str(len(_str))
#7.大小写转换
print "7.大小写转换:"+_str.upper()+","+_str.lower()
#8.字符串转int,int转字符串
print "8.字符串转int,int转字符串:"+str(int("100"))+","+str(100)
#9.分割字符串
print "9.分割字符串:["+_str.split(',')[0]+","+_str.split(',')[1]+"]"
#10.判断字符串是否包含
if _str.find('o,W')!=-1:
print "10.分割字符串:包含o,W"