Math Module
Provides the underlying mathematical function, cos (3.14) =-0.999: ( radians) ACOs (1) = 0.0 sqrt (9) = 3.0 degrees (3.14) = 179.9999: ( Radian to Angle) radians (180) = 3.1415926: ( Angle to radians) constant pi = 3.1415. E = 2.7182..
Cmath Module (complex math, plural)
Support for complex operations, >>>import cmath >>>cmath.sqrt ( -1) 1j >>> (1+2j) * (3+4j) # Python supports complex operations by itself -5+10J
Decimal module
Provides a decimal processing method to avoid the accuracy of binary floating-point numbers 1> decimal (x) converts a string or decimal x to a decimal of the corresponding decimal type, it is recommended to use a string if there is still a conversion accuracy problem with decimals 2> a variety of basic mathematical operations, such as log (), compare (b), sqrt () 3> overloaded +,-, *,/,**
Fractions Module
Provides fractional operations 1> fraction (A, B) converts a fractional A/ B to a fraction of fraction type fraction (x) converts a decimal x to the corresponding fraction fraction, which may not be accurate 2 > overloaded +,-, *,/,**
Random module
Used to generate random numbers 1> random () randomly generates a floating-point number between [0, 1) 2> uniform (L, R) to generate a random floating-point number within the specified range [L, R] 3> randint (l, R) Generates a random integer in the specified range [L, R] 4> randrange (start, stop = none[, step = 1]) randomly generates the random number in range (Start, stop, step) 5 > Choice (Sequence) randomly extracts an element from a sequence, including a string, a list 6> shuffle (x[, random]) randomly disrupting the order of elements in a list 7> Sample (sequence, k) randomly extracts k elements from a sequence to form a list
Time Module
Provides operation for time format 1>-time () returns a number of seconds (timestamp) as a floating-point value starting at 1970.1.1 00:00:00 >>> time.time () 141 3107005.683219 2> CTime ([seconds]) returns the time of the normalized format, if a parameter returns the format time of the corresponding timestamp 3> clock () returns the processor clock time in the UNIX system , it returns the process time. 4> localtime ([seconds]) converts a timestamp to the current time zone Struct_time >>> time.localtime () time.struct_time (t m_year=2014, tm_mon=10, tm_mday=12, tm_hour=17, tm_min=58, tm_sec=22, tm_wday=6, tm_yday=285, tm_isdst=0) 5> gmtime ( [seconds]) Convert a timestamp to the UTC time zone (0 o'clock Zone) struct_time >>> time.gmtime () time.struct_time (tm_year=2014, tm_mon=10, Tm_mday =12, Tm_hour=9, tm_min=59, tm_sec=35, tm_wday=6, tm_yday=285, tm_isdst=0) for struct_time types, we can access them directly to each time unit Sub >>> Time.gmtime () time.struct_time (tm_year=2014, tm_mon=10, tm_mday=12, tm_hour=9, tm_min=59, tm_ Sec=35, Tm_wday=6, tm_yday=285, tm_isdst=0) >>> now = Time.localtime () >>> now.tM_year >>> now.tm_hour >>> now.tm_mday 6> mktime (str Uct_time) converts a struct_time type to a timestamp 7> the sleep (seconds) program stops for a certain amount of time, in seconds 8> asctime ([Struct_time]) Convert a struct_time to a normalized format time 9> strftime (format[, struct_time]) converts a struct_time into a formatted time string >>& Gt Time.strftime ('%y.%m.%d%x ') ' 2014.10.12 18:16:15 ' >>> time.strftime ('%y.%m.%d%h:%m:%s ') ' 2 014.10.12 18:17:54 ' 10> strptime (string[, format]) converts a time string to struct_time the default string format is "%a%b%d%h:%m:%s %Y "
Python3 learning the Tenth bullet: module learning three-digit processing