Home  >  Article  >  Backend Development  >  python赋值操作方法分享

python赋值操作方法分享

WBOY
WBOYOriginal
2016-06-06 11:27:571328browse

一、序列赋值:

x,y,z = 1,2,3

我们可以看作:x = 1,y = 2,z = 3

二、链接赋值:

x = y = 1
print id(x)
print id(y)

大家可以看下,2个执行的结果是一样的。说明变量x和y都是存储了整数对象1的引用地址。

三、增量赋值。

比如x = x + 1 我们可以改成x+=1

掌握上面的3点,相信你对赋值操作有一个很好的了解了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn