Python中的+=是什么意思? [英] What does it mean += in Python?
本文介绍了Python中的+=是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是什么意思:
self.something += ('somethin',)
+="是什么意思?意思是什么,逗号是什么意思?
What does "+=" mean and what does the comma mean?
推荐答案
表达式 a += b
是 a = a + b
的简写,其中 a
和 b
可以是数字、字符串、元组或列表(但两者的类型必须相同).
The expression a += b
is shorthand for a = a + b
, where a
and b
can be numbers, or strings, or tuples, or lists (but both must be of the same type).
('x',)
中的逗号表示这是单个元素 'x'
的元组.如果没有逗号,则只是括号之间的 'x'
.
The comma in ('x',)
means that this is a tuple of a single element, 'x'
. If the comma is absent, is just an 'x'
between parenthesis.
这篇关于Python中的+=是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文