Home >Backend Development >Python Tutorial >How to call a function written by yourself in python

How to call a function written by yourself in python

尚
Original
2019-07-03 16:26:5210165browse

How to call a function written by yourself in python

In python, in addition to calling the downloaded extension library, you can also customize functions to facilitate yourself.
Put the basic module in a fixed folder (or relative fixed folder) and use sys.append(r'custom module path')
The example is as follows:

1. In E: \pycharmCreate a new hello.py to implement the basic function function (define a hello() function)

How to call a function written by yourself in python

2. Call the custom function

How to call a function written by yourself in python

3. The running result is:

How to call a function written by yourself in python

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to call a function written by yourself in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn