Remove "x" number of characters from a string?

This question already has an answer here:

  • Is there a way to substring a string in Python? 10 answers
  • Understanding Python's slice notation 29 answers

  • You can use this syntax called slices

    s = 'gorilla'
    s[2:]
    

    will return

    'rilla'
    

    see also Explain Python's slice notation

    链接地址: http://www.djcxy.com/p/55120.html

    上一篇: Python如何使列表中的所有元素具有一定的长度

    下一篇: 从字符串中删除“x”个字符?