Home  >  Article  >  Backend Development  >  Python intercepts string

Python intercepts string

巴扎黑
巴扎黑Original
2016-11-26 11:56:211245browse

A certain string is stmp="abcdef54321"

Get the first 5 stmp[:5]

Get the next 5 stmp[-5:]

Start from the front, excluding the last two stmp[:- 2]

Get from the 5th to the last stmp[4:]

Get from the 1st to the 2nd stmp[0:2]


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn