首页 > 编程语言 > 详细

python中字符串用法

时间:2018-01-22 16:57:44      阅读:272      评论:0      收藏:0      [点我收藏+]

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

 

  

 

python中字符串用法

原文:https://www.cnblogs.com/pipi-vincent/p/8329602.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!