Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to introduce external functions in python

Shulou Source: shulou.com Published: 2022-05-31 11:13:18 10月03日 Update

In this article Xiaobian detailed introduction of "python how to introduce external functions", the content is detailed, the steps are clear, the details are handled properly, I hope this "python how to introduce external functions" article can help you solve your doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

The specific methods are as follows:

1. Introducing external functions using the imp method

Import imp / / Import imp module

Text=imp.load_source ('text','D:/text.py') / / text.py file path

Import text

If _ _ name__== "_ _ main__":

Print text.pr (xperiin y) / / introduces the pr (xperiary) function in the text.py file

two。 Introduce an external function by calling the path in which it is located

Import sys / / Import sys module

The path to the sys.path.append ('DVU _ plank') / / text.py file

Import text

If _ _ name__== "_ _ main__":

Print text.pr (xperiin y) / / introduces the pr (xperiary) function in the text.py file

After reading this, the article "how to introduce external functions in python" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.

Tags: Functions documents articles paths contents methods modules proper ideas locations new knowledge more steps knowledge knowledge points articles details industries information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker MySQL Shulou Information Huawei