Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of python Import Module

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the python import module example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian with you to understand.

1. Execute a .py file, open up new memory, and put the imported things into memory, so that you can get them directly from memory by calling.

2. When there are more and more modules, it is necessary to manage the modules through packages.

Example

# call in the package file (usually at the beginning of the import statement) import harryimport magicprint (harry.name) harry.Fight () c = harry.Course ('Harry') c.add_course ('Defense against the Dark Arts') magic.use_magic () # module rename import harry as hy # to prevent the module name from being too long to rename # import method 2from harryimport namefrom harryimport Fightfrom harryimport Courseprint (name) Fight () c = Course ('Harry') c.add_course ('Defense against the Dark Arts') # this method does not need to use harry. The method, which is equivalent to declaring the source in advance and simplifying the logic, can also play the role of introducing a specific variable and a specific function characteristic class. # from harry import name# from harry import Fight# from harry import Course can also use the following expression instead of simplifying the code from harry import name, fight, Course or from harry import * # to import everything into thank you for reading this article carefully. I hope the article "sample Analysis of python Import Module" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report