Example Analysis of Python data structure creation
This article shows you an example analysis of the creation of Python data structures, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. List list: variable assignment method: shoplist = ['apple',' mango', 'carrot',' banana']
two。 Tuple array: variable assignment method: zoo = ('wolf',' elephant','penguin')
3. Dictionary dict: variable assignment method: d = {key1: value1, key2: value2}
4. Sequences: lists, tuples, and strings are all sequences
(1) Index operator: gets a character of an element or string in a list / tuple
(2) slice operator: get a slice of a sequence, consecutive elements / characters
(3) eg:
Name = 'swaroop' print' characters 0 is', name [0]
Slots, index operator, similar to C #
Print 'characters 1 to 3 is', name [1:3]
'The wa' slicing operator, similar to the Substring method in C#
In fact, Python contains a lot of content, such as Python is different from the traditional interpreted scripting language, it will be compiled into bytecode when it is executed * *, and then the bytecode will be run directly. This .NET DLR is a bit similar to Java's virtual machine, in short, it is a way to convert the code closer to machine code, which can improve performance.
Many people say that Python,Ruby is a working language and Java is a weekend language. In fact, languages communicate with each other. If you learn more, you can broaden your horizons. It is also a guarantee to choose one of them to learn when agile development is so hot, isn't it? If you touch Python, I'm sure you'll like it.
The above is a sample analysis of the creation of Python data structures. have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.