Python executes python script commands, and the command line runs python programs

This article will talk about how to close the session by executing a python script on the command line and how to run a python script on the command line. I hope it will be helpful to you. Don’t forget to bookmark this site.

1. Prerequisites

1.Have installed python and its own idle

2. If the folder is on a non-C drive, see solution 2-1-(1) below.

2. Specific steps

1. Open the terminal under Windows

hot key:

win+r

Enter cmd in the box (usually the default is cmd)

Enter

Open the back picture

(1) If the folder is not in the C drive

Use the D: or E: command to switch drive letters

2. Use the cd command and dir command to find the python file you want to edit and run. If it has not been created yet, you can use it.

type nul> *.py //* refers to the file name

Create python file

The final effect is as shown below

3. Edit and run python files

edit:

idle *.py

 The effect is as shown in the figure

run:

python *.py

 The effect is as shown in the figure

3. Expand knowledge

1. Create and delete files, folders, and clear the screen under the Windows command line

Create an empty file: type nul>*.* //*.* refers to the file name. Suffix name

Create a non-empty file: echo *>*.* //The first * refers to the content in the non-empty file, the next two * are the same as above

Delete files: del *.*

Create a folder: md or mkdir * //* refers to the file name

Delete folder: rd or rmdir * //If the folder is empty, delete it directly. If the folder is not empty, ask to delete it.

Clear screen: cls

2. Windows command line installation tips

(1) Modify the window name

use:

title * //* refers to the content to be modified

You can modify the command line window name

The effect is as shown in the figure 

(2) Modify color matching

use:

color ** //** refers to two hexadecimal numbers, representing the background color and font color

The colors of the windows command line window are as follows

 final effect:

 3. How to use the windows command line query command

* /? //* refers to the command

The effect is as shown in the figure 

Guess you like

Origin blog.csdn.net/mynote/article/details/132797776