In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the python index in the order and reverse order of the example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Description
1. Python supports not only sequential indexing, but also reverse indexing.
2. The reverse index refers to the index calculated from right to left, and the rightmost index value is-1, which decreases in turn.
3. Note that the reverse order is the same as the order subscript, and both are unsubscribed subscript elements.
Example
Num_str = "0123456789" # 1. Intercept the string print (num_str [2:6]) # 2 from positions 2-5. Intercept the string print (num_ str2:]) # 3 from the end of 2 ~ ``. Intercept the string print (num_str [: 6]) # 4 starting from `~ 5. Intercept the complete string print (num_str [:]) # 5. Intercept the string print (num_str [:: 2]) # 6 every other character from the start position. Starting with index 1, take every other print (num_ str1:: 2) # 7, and reverse slice #-1 represents the penultimate character # all character sequences print (num_ str1:-1]) # 8 with index 1 to the penultimate string. Intercept the string print (num_ stre [2:-1]) # 9 from 2 ~ `\ end-1`. Intercept the last two characters of the string print (num_str [- 2:]) # 10. String reverse (interview questions) print (num_str [::-1]) Thank you for reading this article carefully. I hope the article "sample Analysis of order and reverse order in python Index" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.