System environment: Ubuntu18.04
Python: 3.8.1
Ubuntu installation tutorial: xiaolong.blog.csdn.net/article/det…
1. Download the VScode installation package
Download the Linux installation package from the official website.
Download: code.visualstudio.com/
2. Install VScode
3. Set vscode to support Chinese
Set Up Visual Studio to support Chinese, open Visual Studio, press F1 or Shift + Ctrl + P:
On the CLI, enter Configure Display Language and press Enter to confirm the installation Language.
4. Install Python extension support and run code tests
5. Solve the problem of large font spacing in VScode built-in terminal
Set the font of the terminal to monospace
6. Write your first Python program
Every programming language has its own set of syntax. The compiler or interpreter is responsible for converting the syntactic program code into machine code that the CPU can execute and then execute. Python is no exception and has its own syntax rules and parsers.
Python programs are case sensitive and will report an error if you write the wrong case.
Python’s most distinctive feature is the use of indentation to represent blocks of code, without the use of curly braces {}
The number of indented Spaces is variable, but statements in the same code block must contain the same number of indented Spaces. An inconsistent number of indented Spaces will result in a runtime error.
An example of Python code:
#! /usr/bin/python3
print("hello Python");
if True:
print ("True")
else:
print ("False")
Copy the code
The number of indented Spaces is inconsistent, the following code runs with an error:
#! /usr/bin/python3
print("hello Python");
if True:
print ("True")
else:
print ("False"# This code block is not aligned with the above code block/* Error: PS C:\Users\11266> & C:/Users/11266/AppData/Local/Programs/Python/Python38-32/python.exe d:/linux-share-dir/Python/python_code.py File "d:/linux-share-dir/Python/python_code.py", line 7 print ("False") ^ IndentationError: expected an indented block */
Copy the code