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