Configuring the Python environment in notepad++

Source: Internet
Author: User
Tags python script

First, choose Python in the language.

Then click Run, and in the Pop-up dialog box, enter:

Cmd/k cd/d "$ (current_directory)" & Python "$ (full_current_path)" & ECHO. & PAUSE & EXIT

Then click Save, enter the name of the shortcut key, such as Runpython, and then define the shortcut keys, such as Ctrl+f5. After writing the code, just press CTRL+F5 to run the program.

Explain:

Where cmd/k means to open the CMD command line and then run the command after/k

Cd/d "$ (current_directory)" in:

The CD command represents the switch to the current working directory

/d is a parameter to the CD command, which indicates that the directory you want to switch to is not on the same partition, plus/d, otherwise the CD will not pass.

$ (current_directory) represents the directory where the current source program files are located

& used to connect two commands, sequential execution

Python: Python can run directly to Python.exe because it previously set the path in the environment variable

$ (Full_current_path) refers to the full path of the current file

Echo: Line break

Pause: Indicates a pause after running (cmd displays "Press any key to continue ..."), waiting for a key to continue

Exit: Indicates "Press any key to continue ..." to close the command line window.

Because Python is a language that is sensitive to spaces and indents, you need to make the settings relevant.

First set the tab to 4 spaces, select Settings-Preferences, and then action. As shown in.

And then set--Other, select Auto Indent

Then select in the format utf-8 no BOM format encoding

Additionally, when you are finished programming, you may have errors such as the following indentation in the process of running:

Syntax error in Python script run: Indentationerror:unindent does not match any outer indentation level.

First of all, look at the error before and after the line, if and so on after the leakage of ":", or ":" After forgetting to indent.

Another possibility is that the tab and the space are mixed. Although we have already set the tab to automatically turn 4 spaces, it is sometimes possible to mix tab and space. Like copying and pasting code from somewhere else. This time select View-show symbol-Show all characters. The space is displayed as a point, and the tab appears as an arrow. As shown in.

Configuring the Python environment in notepad++

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.