美文网首页
python 入坑之路一 《字符串运算》

python 入坑之路一 《字符串运算》

作者: Coderliszt | 来源:发表于2020-04-24 22:31 被阅读0次

    # # # # # # # # # # # # # # # # # # # # #

    # # 微信公众号 # # # #

    # # # <编程生涯> # # # #

    # # # # # # # # # # # # # # # # # # # # #

    # 截取字符串 第一位
    print("hello world"[0])
    # 截取最后一位字符串
    print('hello world'[-1])
    # 从多少下标截取到多少下标
    print('hello world'[0:3])
    # 还可以这样截取
    print('hello world'[0:-1])
    
    
    # 作业标题 用两种方式截取world
    
    # 第一种
    print('hello world'[6:11])
    # 第二种(输入第一个下标,第二个什么都不输入就会自动截取到最后)
    print('hello world'[6:])
    

    相关文章

      网友评论

          本文标题:python 入坑之路一 《字符串运算》

          本文链接:https://www.haomeiwen.com/subject/zcccwhtx.html