python基础(一)——字符串

1.分割字符串split

>>> filename = "iamge.png"
>>> segments = filename.split(".")
>>> segments[0]
'iamge'
>>> segments[1]
'png'

2.查找特定字符串

>>> dir=r"C:\Users\username\haha\app\haha"
#反向查找
>>> dir.rfind("haha")
27
#正向查找
>>> dir.find("haha")
18

3.拼接字符串

>>> "hello"+" python"
'hello python'

 

posted @ 2016-06-26 17:40  听懂·动听  阅读(172)  评论(0编辑  收藏  举报