In a program, folders are generally included: Bin, Conf, Lib, data, logs, and readme files.
How do I concatenate the programs that are written to the respective folders?
First, import the module by importing the file, referencing code written by someone else.
Second, find the top-level program in the folder, add to the environment variable
Import Sys,os
Base_path = Os.path.dirname (Os.path.dirname (Os.path.abspath (file))) #取到工程目录
Sys.path.insert (0,base_path) #加入环境变量
From Lib.main Import server #导入lib目录下的main. py file.
Server.run (port=8000,host= ' 127.0.0.1 ', debug=true)
Description
1, Os.path.abspath (file) Get the current file path
2, Sys.path.insert (0,base_path) Add environment variable, do not see in the system environment variable
3, the host=0.0.0.0 can be the same LAN inside everyone can access
Python Learning Notes (11)-python Program Catalog Engineering