Python slice parsing,

Source: Internet
Author: User

Python slice parsing,

Slice prototype strs = 'abcdefg'

Strs [start: end: step]

 

The three parameters of the slice are table start, end, and step size respectively.

The first subscript is 0, and the end bit is not obtained, for example, strs [] = 'bc'

If start and end are out of the range of the existing array, truncate strs [-100:100] = 'abcdef' according to the actual range'

 

Strs [] = 'bcde' strs [] = 'bd'

Strs [5:1] =''

Start is blank. The default value is negative infinity strs [: 4] = 'abcd'

End is blank. The default value is infinite strs [2:] = 'cdefg'

Strs [:] = 'abcdefg'

Strs [1: 5:-1] =''

Start is blank. The default value is infinite strs [: 2:-1] = 'gfed'

End is blank. The default value is negative infinity strs [4:-1] = 'edba'

Strs [:-1] = 'gfedcba'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.