整理Python中的赋值运算符
程序员文章站
2022-04-12 09:53:49
下表列出了所有python语言支持的赋值运算符。假设变量a持有10和变量b持有20,则:
例如:
试试下面的例子就明白了所有在python编程语言可...
下表列出了所有python语言支持的赋值运算符。假设变量a持有10和变量b持有20,则:
例如:
试试下面的例子就明白了所有在python编程语言可供选择的赋值运算符:
#!/usr/bin/python a = 21 b = 10 c = 0 c = a + b print "line 1 - value of c is ", c c += a print "line 2 - value of c is ", c c *= a print "line 3 - value of c is ", c c /= a print "line 4 - value of c is ", c c = 2 c %= a print "line 5 - value of c is ", c c **= a print "line 6 - value of c is ", c c //= a print "line 7 - value of c is ", c
当执行上面的程序,它会产生以下结果:
line 1 - value of c is 31 line 2 - value of c is 52 line 3 - value of c is 1092 line 4 - value of c is 52 line 5 - value of c is 2 line 6 - value of c is 2097152 line 7 - value of c is 99864
上一篇: vue-router导航卫士
下一篇: vue组件插槽,路由,生命周期,路由卫士