python学习笔记

1.python中的赋值,与C语言相比,没有返回值。

>>> x = 1
>>> y = (x = x + 1) # assignments not expressions! File "<stdin>", line 1
y = (x = x + 1)
^
SyntaxError: invalid syntax

2.python的“多元”赋值:

>>> x,y,z=1,2,3  #或 (x,y,z)=(1,2,3)
>>> z
3
>>> x
1

“=”两边的值都是元组。

原文地址:https://www.cnblogs.com/limingluzhu/p/2720273.html