29

Python中a += b 并不一定等价于a = a + b

 3 years ago
source link: https://juejin.im/post/5c504bace51d450d064623f0
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
大家经常在一些博客中看到这样的说法: a += 1 复制代码等价于 a = a + 1 复制代码这种说法实际上并不准确。 我们来看一个例子: >>> a = [1, 2, 3] >>> a += (4,) >>&

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK