Python Learning Notes (11)-python Program Catalog Engineering

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.