python中字符串用法

s = "This is a test string"

1.索引

s[0] = T

s[1] = h

2.长度

len(s) =>21

3.切片

s[0:2] =>Th

4.循环(continue 和 break)

for item in s:
    if item=='h':
        continue
    print(item)
View Code

 

  

 

posted @ 2018-01-22 16:21  pipi_vincent  阅读(118)  评论(0)    收藏  举报