zoukankan      html  css  js  c++  java
  • DAY 004--str(连接、复制、切片、索引)

    字符串的基础操作:                                                                 

    1、str1 + str2                                                                                                     

    • 将字符串连接
    s1="abc"
    s2="123"
    print(s1+s2)
    
    abc123

    2、str * num                                                                                                   

    • 将字符串复制num次
    s1="abc"
    print(s1*3)
    
    abcabcabc

    3、str[index]                                                                                                  

    • 字符串的索引值
    s1="abc"
    print(s1[0])
    
    a

    4、str[index:index:step]                                                                                  

    • 切片操作
    s1="abcdef"
    print(s1[2::2])
    
    ce

      

     Mark on 2018.4.6

  • 相关阅读:
    NSIS制作安装程序
    poj_1011木棒
    hdoj_1312Red and Black
    搜索题目推荐及解题报告
    应届生就职前要读的几本书
    poj_1564Sum It Up
    priority_queue用法
    hdoj_2952Counting Sheep
    poj_1154LETTERS
    poj_2362
  • 原文地址:https://www.cnblogs.com/JunSheep/p/8733856.html
Copyright © 2011-2022 走看看