The first step:
try to write Hello world program
This is the first program I wrote in python, one small step, One big step in my Life.
Create a file under Linux called hello.py,
Then execute the command: python hello.py, output
Specify interpreter (refer to Alex Teacher's Summary)
When executing Python hello.py in the previous step, it is clear that the hello.py script is executed by the Python interpreter.
If you want to execute a python script like executing a shell script, for example:./hello.py, then you need to specify the interpreter in the header of the hello.py file,
As a result, execute:./hello.py.
Ps: need to give hello.py Execute permission before execution, chmod 755 hello.py or chmod a+x hello.py
variables \ character encoding
Declaring variables,
The above code declares several variables, for example: the variable is named: name, and the value of the variable name is: "liyasen"
Rules for variable definitions:
- Variable names can only be any combination of letters, numbers, or underscores
- The first character of a variable name cannot be a number
- The following keywords cannot be declared as variable names
[' and ', ' as ', ' assert ', ' break ', ' class ', ' Continue ', ' def ', ' del ', ' elif ', ' else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' Print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']
Assigning values to variables
~ Aibirong ~ Python Basics for Learning python