Introduction module: execute a file, that is, the implementation of a module, py when naming the file name, can not create a python module built in the same name in the current directory, otherwise it will not call
import
form () import (): import place from which nothing can be seen as a path in front, the back is something you want to import, import * is so (not advocated because it may cause the variable name is repeated, resulting in error!)
time module:
time.time (): Gets the time stamp, from the beginning of 1970 to the present, spent a total of how many seconds
time.sleep (): delay the execution, how many seconds the program to sleep
time.loacltime (): Gets the timeline. Law Act can be displayed directly by calling
time.strftime ( "% Y-% m-% d% X", time.localtime ()): The time stamp is converted to a column such as 2019-12-14 15:12:21
time.strptime (): the time into the form of a time stamp, must correspond
random module:
random is a random block module can get some random value
random.random (): Get a random number between [0,1)
random.ranint (): Get a random value within the range of
random.ranrange (): Get a random value (inclusive) in the range
random.choice ([x, y]): From the x, y which randomly
random.sample ([x, y], 2): two random values acquired
sys module:
sys module: This module provides access to some variables used or maintained by the interpreter, as well as a function of the strong interaction with the interpreter. It is always available.
sys.path: Returns the search path to the module, using initialization value of the environment variable PYTHONPATH
sys.path.append (): Add search path
os module
os module operating on the operating system
Gets the absolute path of the file: os.path.abspath ()
os.path.dirname (): directory name
os.getcwd (): Gets the current working directory that the current directory path python script work
os.chdir ( "dirname"): change the current working directory script; cd at the equivalent of shell
os.makedirs ( 'dirname1 / dirname2'): may generate a multi-level directory
os.remove (): Delete a file
os.path.join (): can be spliced directory
os.path.isfile (): determines whether the file exists, returns a Boolean value
os.path.isdir (): whether or not directory, returns a Boolean value
sys module:
sys.argv (): it may be used to store the data input by the user for storage
sys.stdout.write ( "*"): the equivalent of print
sys.stdout.flush (): The data refresh only memory