Generally speaking, we will store the python module written by ourselves and the module brought by Python separately to achieve the purpose of easy maintenance.
When the python runtime environment looks for the library file, the sys.path If we want to register a new class library in the running environment, there are three main methods:
stay sys.path Add a new path to the list.
Set the pythonpath environment variable.
Copy library files to sys.path List in the directory (such as the site packages directory).
In fact, the simplest way is to use. PTH file to achieve. When Python traverses the known library file directory, if it sees a. PTH file, it will add the path recorded in the file to the sys.path In this way, the library specified in the. PTH file can also be found by the python runtime environment.
Create one in the python / lib / site package directory MyModule.pth File, where the content is the path of the customized module.
C: In this way, the python files in the project directory can be found.
Python implements custom add save & delete function?
Now we have a simple GUI interface
rules = easygui.multchoicebox (MSG =’Please select the rule ‘, title =’test’, choices = [‘function 1 ‘,’function 2’,’custom function ‘])
Functions 1 and 2 are written and can be implemented. This custom function allows users to determine one of the parameters themselves, and the rules have been written in advance. For example, add a string x to the input, which allows the user to define it.
- Now the problem is that every time a user customizes a function, you need to re-enter it when you use the GUI interface again.
Is there any way to save the rules used by users before? You can select them directly next time you use them, or you can delete them when you don’t need them.
If you ignore the easygui framework, you only need to implement the idea, how to operate?
A: to save it, you can store it in physical storage, file form, or database table (you can use the pickle library to access simple data), and the program will start to read it.
Xiaobian is also learning python, so they are more concerned about these issues. If you are also interested in Python and there is no professional teacher around, you can add q878 java788.. C + +,, 853, together to explore learning.