Original source code and web page address
Python basis
Comment Syntax
" " #
No comment syntax is python, written on the front of the language you want to comment. as follows:
# 我就是一行注释语言,你看也白看~
- " "
#
Any number of data output will not be back at the stage of code to run.
Define the variable
Definition of variables and variable assignments
name='python'
# name就是变量,一个“=”号进行赋值。值为字符串“python”
In the code of the world, the assignment symbol = (equal sign) is not equal to the left of the right meaning. Action only for assignment: to put the right content to the left box.
Representative of the left and right sides of the equal sign is the comparison operator == (double equal sign)
Modify variable values
The final value of the variable is equal to the last value assigned.
name='python'
name='小石头学python'
print(name)
# 最终输出结果:小石头学python
Variable naming convention
- Only one word
- Names can only contain numbers, letters, underscores
- You can not begin with a number
- Semantic far as possible, their meanings description comprising
- Do not use python function names and keywords
Malformed
A, syntax error: syntaxError: invalid syntax
This is usually because the python with the Chinese symbol caused.
In Python, by default all the correct grammar, punctuation are included [English].
Chinese careless use of punctuation, then the computer will not recognize, then an error syntaxError: invalid syntax (syntax error: invalid syntax).