赋值运算符
运算符 | 描述 | 实例 |
---|---|---|
= | 赋值 | 将=右边的结果赋值给等号左边的变量 |
- 单变量赋值
- 多变量赋值
# 单变量赋值
num = 1
print(num)
# 多个变量赋值
num1, float1, str1 = 10, 0.5, 'hello world'
# 多变量赋相同值
a = b = 10
运算符 | 描述 | 实例 |
---|---|---|
= | 赋值 | 将=右边的结果赋值给等号左边的变量 |
# 单变量赋值
num = 1
print(num)
# 多个变量赋值
num1, float1, str1 = 10, 0.5, 'hello world'
# 多变量赋相同值
a = b = 10