In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.