Part 2: Basic knowledge of Python

1. Run:

  Create a hello.py file in the D:\python_test\ directory with the following contents:

1 #! /user/bin/local/ python
2 # -*- coding:utf-8 -*-
3 
4 print("hello world")

  There are usually two ways to run Python files under Windows:

    1. Open the terminal ---> C:\Program Files\Python36\python3.exe D:\python_test\hello.py, that is, enter the running path + file path of Python3 to run the python file.

    2. Run the Python interpreter --> open C:\Program Files\Python36\python.exe to execute the python file.

  The execution process inside Python is as follows:

 

Second, the file line

    When we open a Python file, there will usually be #!/user/bin/local python at the head of the file, for example:

#! /user/bin/local python

print(" hello world")

    This means that when executing under Linux, the first line is read when the file is opened, and the path to the python interpreter is found through it to execute the file. If you enter directly in the Linux terminal:

>>> python hello.py

It doesn't matter if the sentence is added or not.  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325028970&siteId=291194637