python基础知识

1.   count (str,startiinaex,enainaex)  统计查找字符在指定字符串出现的次数
列如:
        print("hello".count("h"))
 
2.replace(old,new) 字符串替换
列如:
    print("hello world".replace("world","python"))

  

 
3. split( str , num)   指定分割符
列如:
    print("hello".split("e"))

  

4. capitalize()  字符串单词首字母大写
列如:
    add='add shi ke yi ren yi gai bian de '
    print( add.capitalize())

  

5. title()  字母转换成大写
列如:
    add='add shi ke yi ren yi gai bian de '
    print( add.title()

  

6. lower() 字母转换成小写
列如:
        add='add shi ke yi ren yi gai bian de '
    print(add.lower())
7.  lstrip()   删除左边字符串的空白字符
    rstrip()   删除字符末尾的空白字符
    strip()    删除字符串两边的空白字符
posted @ 2018-11-27 16:03  浮生若梦不悔  阅读(84)  评论(0编辑  收藏  举报