1.字符串的索引

Python 字符串_python

    

   2.字符串的切片

   s[1:3]   从第二个数切片到第三个,上边界不包含在内。

     s[3: ]

     s[ :3]   没个给切片的边界,上边界默认是0,下边界默认是末尾。’

     s[  ]   从0到末尾的全部元素。

Python 字符串_python_02


   3.判断字串

    *判断字符是否属于字符串

Python 字符串_python_03   

   4.重复,连接,计算字符长度

Python 字符串_python_04

   5.字符常用操作

    * haha.caritaliz() 将字符首字母大写并返回输出

Python 字符串_python_05    * haha.center(20.‘*’) 返回长度为20的字符串,原字符居中,其它部分用*填充,默认是空格

Python 字符串_python_06    * haha.count("e")  统计e在字符串中出现的次数,0,7 定义查找的位置

Python 字符串_python_07    * haha.startswith( ) haha.endswith( )  判断字符是否以括号内的内容开头或结尾

Python 字符串_python_08

    * haha.find("w") 判断w是否在字符串中

     haah.index("m")


Python 字符串_python_09   

   *

Python 字符串_python_10

   *  "*".join(haha) 以*为分隔符,将字符串中所有元素合并为新字符串

Python 字符串_python_11 

  

   * haha.replace("man","haha") 将字符串中的man替换为haha

Python 字符串_python_12 

    

   * haha.split("-") 以-为分隔符对字符串分割,默认是空格

Python 字符串_python_13

   * haha.strip("ed") ##返回字符串,删除结尾的ed 

Python 字符串_python_14