How to implement named slicing in python
This article is about how Python implements named slices. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
named slice
In Python, splitting lists is easy and can be done with a variety of excellent tools. Especially nice is the ability to name lists, which is especially useful for linear algebra in Python:
a = [0, 1, 2, 3, 4, 5] LASTTHREE = slice(-3, None) slice(-3, None, None) print(a[LASTTHREE])
Thank you for reading! About "python how to achieve naming slices" This article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!