- Python is a dynamic type and can be viewed with type ().
- Python object (object is an instantiation of a class, three main concepts encapsulation, inheritance, polymorphism);
- : Divide the symbol;
- Decimal type: High-precision numeric type, but not high efficiency;
- Common functions for numeric types: Import Math
- math.pi:π
- MATH.SQRT (80): Open square root
- MATH.LOG10 (2**1000): Log base 10
- Math.pow (x, y): x y-square
- Math.factoria (x): factorial
- Common functions for numeric types: import random
- Random.random (): Generates a random number between 0 and 1
- Random.choice ([1,2,3,4]): Randomly select one in the list
- Random.randint (b): Randomly select an integer between A and B
- Random.uniform (b): Random number evenly distributed between A and B, floating-point numbers
- Random.gauss (MU,LAMDA): Random number of Gaussian distributions, mu mean, lamda variance
- NumPy: Generating arrays or matrices, random numbers of normal distributions, matrix operations, inversion, transpose;
- SCIPY: Fitting, linear interpolation, spline interpolation, integral, differential, non-linear equation, filter design;
- String: Slice, index (String[1],string[1:3],string[1:6:2] Three parameters are Start,end,step,)
- String method: Split slice, join connection
- String Common methods: (1) "+" is combined before and after, (2) "*" Repeating composition, (3) S.upper () All Thank you, (4) s.find (' Pa ') to find the character containing PA, (5) s.replace (' Python ', ' Java ') ' Python ' replaced with ' Java '; (6) Substitution of variables in "%s" output string in print
- String-re module: Import re
- Re.match (P,text): Start with the string text header to find p, only return a match object, no return none;
- Re.search (p,text): Find p from the entire string text, return only a match object, no return none;
- Re.findall (P,text): Returns multiple results in the form of a list;
- Re.split (P,text): Splits the string, separating it according to the P character;
- Re.sub (p,s,text): Find p to replace p to s;
- 11 metacharacters in Python: \ ^ $. | ? * + () [] {}
- 11 metacharacters-Special meaning: \ (escape character). (denotes all characters except carriage return)
- 11 metacharacters-Optional: | (or), [] (OR)
- 11 metacharacters-Repeat: * (character repeats 0 or infinitely), + (character repeats once or infinitely),? (0 to 1 characters), {} (repeat word count, first parameter minimum repetition count, second parameter max repetition), ^ in [] mean non, *? (),+? (as few as possible)
- 11 Metacharacters-6 character classes: \d (0-9), \d, \s (\t\n\r\f\v), \s, \w (a-za-z_), \w (uppercase corresponding to the small W's non)
- 11 metacharacters-4 position classes: \b (boundary of word), \b (non-small B), \a (input start), \z (input end), (^ start, $ end)
- 11 metacharacters-Group: ()
- Re.findall (R ' ^c. ', text): Search from scratch for character ' C '? ' ... ' Two non-carriage return characters;
- Re.findall (R ' ... R $ ', text): Search from the end to ' ... ' Two non-return characters? character ' R ';
- Compilation options: I, L, M, S, U, X
Notes (doing things in Python)--variables (numbers, strings)