python赋值操作方法分享

WBOY
Release: 2016-06-06 11:27:57
Original
1437 people have browsed it

一、序列赋值:

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点,相信你对赋值操作有一个很好的了解了。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template