How does python call its own function

In python, in addition to calling the downloaded extension library, you can also customize functions for your convenience.

Put the basic module in a fixed folder (or a relatively fixed folder), use sys.append(r'custom module path')

Examples are as follows:

1、 Create a new hello.py in E:\pycharm to implement basic functions (define a hello() function)

2、 Call a custom function

**3、 The running result is: **

Content expansion:

How to call a function written by yourself in Python

For example, I now write a KNN function, as follows:

import numpy as np

def createDataSet():
 group=np.array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]])
 labels=['A','A','B','B']return group,labels

If you want to quote in another .py file

First import kNN

Reference function kNN.createDataSet()

Recommended Posts

How does python call its own function
How does python call java classes
How does Python call cmd using OS modules
How does python output backslashes
How does python call the key of a dictionary
How Python implements FTP function
How does python update packages
How does python perform matrix operations
How does Python list update value
How Python implements the mail function
How does python change the environment
How does python import dependency packages
How does python enter interactive mode
How does Python generate xml files
How Python implements the timer function
How does python determine prime numbers
How does python improve the calculation speed
How to run id function in python
How does Python handle the json module
How does python distinguish return and yield
How to use the round function in python
How to use the zip function in Python
How to use the format function in python
Python enumerate() function
Python function buffer
How does Python store data to json files
How does python get input examples from the keyboard
How does python handle the program cannot be opened
How does python judge the module installation is complete
Python custom function basics
Join function in Python
Python built-in function -compile()
Python function basic learning
Python data analysis-apply function
Python3 built-in function table.md
How python was invented
Python Print print timer function
How Python parses XML
How long does it take to learn python by myself?