What are the common built-in modules in python
Editor to share with you what python commonly used built-in modules are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
When you import a module, you automatically do three things: 1. Run all the code in the module (make sure there is no bug in the module) 2. Generate a namespace with the same name as the module name 3. 0. Let the running program connect to the namespace, and then you can use the variables / functions in the module: _ _ name__, if the py file is run as a program, _ _ name__ = 'main', if it runs as a module, _ _ name__ = file name time-time module import timetime.sleep (2) # program paused Unit second # get timestamp print (time.time ()) # format output time print (time.strftime ('% Y-%m-%d% HV% MV% S')) sys-system module import sys# acquires environment variable print (sys.path) print (sys.version) print (sys.platform) random-any time module import random# generates a random number print ('.3f'% random. Random () print (random.randint (1100)) # randomly take a value from the sequence li = [1pc2 3J4] c = random.choice (li) print (c) # disrupts the sorting of a list random.shuffle (li) print (li) os-operating system module import os# gets the current file location pwdprint (os.getcwd ()) # create a new folder os.mkdir ('aaa') os.sep # get the file separator of the operating system above is all the content of the article "what are the common built-in modules in python" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!