Article From:https://www.cnblogs.com/louis0815/p/9061884.html

1、Declarations variable

1
2
3
4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
  
name = "wupeiqi"

The above code declares a variable, the variable name is name, and the value of variable name is: “wupeiqi”.

The function of variables: nicknames, which refer to the contents stored in an address in memory.

The rules of the variable definition:

  • Variable names can only be any combination of letters, digits, or underscores.
  • The first character of a variable name can’t be a number
  • The following key can not be declared as a variable name
    [‘and’, ‘as’, ‘assert’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘exec’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘not’, ‘or’, ‘pass’, ‘print’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]

2、The assignment of variables

#!/usr/bin/env python
# -*- coding: utf-8 -*-

name1 = "wupeiqi"
name2 = "alex"
 
#!/usr/bin/env python
# -*- coding: utf-8 -*-

name1 = "wupeiqi"
name2 = name1

Leave a Reply

Your email address will not be published. Required fields are marked *