1. fragmentation step, the default value of 1, denoted xx [s: t: v] ---- index from the index s to t, every v, taking a position corresponding to the index value
= XX ' Hello, World ' # from 0-10 index of 11 characters XX [ 2:] # from the index values 2 until finally all of the Out [2]: ' LLO, World ' XX [ . 1:. 5: 2] # from 1 to 5 indices, i.e. xx [1: 5] = ' ello', note that this case does not contain xx [5] values from xx [1] start, take every 2 a value, i.e., take XX [. 1], XX [. 3] Out [. 3]: ' EL ' XX [:: 2] # for the entire sequence, at the end of this time sequence comprises values from xx [0] beginning, every take a value of 2, i.e., taken xx [0], xx [0 + 2], xx [2+ 2], XX [. 4 + 2], XX [2. 6 +], XX [2 +. 8] Out [. 4]: ' hlowrd ' # # Note: python index is zero
2. The step is negative, and sometimes useful, for example, reversing the sequence
# # Note: python when negative index, a last index sequence is -1, so from right to left, followed by -1, -2, -3, ... XX [:: -1] # can be appreciated to first take the entire sequence, starting with index 0 and then sequentially taken xx [0-1] is xx [-1], xx [-1-1 ] is xx [-2], xx [-3 ], .. . the value of the sequence is reversed Out [. 6]: ' dlrow, olleh ' XX [ 7: 2: -1] # based index of 7, each -1, reverse sequence, i.e. xx [7], xx [6 ], ..., but also does not contain xx [2] value OUT [. 7]: ' OW, OL '
3. The string-to-digital, digital-to-string
int ( ' 30 ' ) # '30' is itself a string Out [9]: 30 float('30') Out[10]: 30.0 str(30) Out[11]: '30'
4. The conversion to the ASCII code
the ord ( ' A ' ) # the ord function to get the ASCII value of Out [12]: 97 CHR ( 97) # CHR function to obtain the corresponding ASCII characters Out [13 is]: ' A '
The complex representation
-4j + 2 # is generally used a method easier to see below, you can obtain a plurality 2-4j Out [14]: (2-4j ) 2-4j Out[15]: (2-4j)
6. bitwise and, bitwise or
1 & 2 # binary: 0001 & 0010 = 0000 Out [18 is ]: 0 1 & 1 # 0001 & 0001 = 0001 Out[19]: 1 1 | 2 # 0001 | 0010 = 0011 Out[21]: 3
7. divide (/) with a division floor (//)
5/3 # direct division Out[16]: 1.6666666666666667 //. 3. 5 # Floor result of the division, the largest integer less than 1.66666666666666667 taken, i.e. 1 Out[17]: 1 5 // --3 # largest integer less than -1.66666666666666667, i.e. -2 Out [22 is]: -2
## Note: '%' is a number corresponding to the operand fetch I
8. math.floor function and math.ceil
import math Math.floor ( 5/3, ) # division explained with floor Out[25]: 1 math.floor(5/-3) Out[28]: -2 Math.ceil ( 5/3,) # smallest integers greater than the 1.666666666667 Out [26]: 2 Math.ceil ( . 5 / -3) # takes the smallest integer greater than -1.6666666666667 Out [27]: -1