Python-----Environment variables

Source: Internet
Author: User

I. How do I add environment variables?

1. Right-click Add environment variable, select the directory to which you want to add environment variables----> right----->mark directory as------>sources Root

Add an environment variable to a file that turns blue

2. Via Sys.path.append (' directories to add environment variables ') or Sys.path.insert (0, ' directories to add environment variables ')

To obtain the absolute directory of the current directory as a reference, through the current directory to join the environment variable directory. Then add the environment variable

This is the recommended way to run your code on the command line or someone else without error.

Print (__file__) #不管什么时候, gets the absolute path to the current Python file

Get the current directory dynamically by '-file-', then take the correct path delimiter for the current file, and then take the parent directory or parent directory as required ....

Python-----Environment variables

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.