Home > Article > Backend Development > How to use variables in Python_How to use variables in Python
1. First of all, friends who have learned C language know that if you want to use variables in C language, you need to define a type of variable before you can use it.
2. Then in the Python language, there is no need to define it in advance, you can just assign it directly where it is used.
3. The Python compiler will automatically assign a data type based on the data to which the variable is assigned.
4. Global variables defined in C language need to be outside the function.
5. Then Python can also define global variables, which need to be declared outside the function.
6. When using external global variables in a function in C language, you can use them directly without declaring them.
7. Finally, when using python global variables, they need to be declared with global in the function, otherwise they will be considered new local variables.
The above is the detailed content of How to use variables in Python_How to use variables in Python. For more information, please follow other related articles on the PHP Chinese website!