Vor*_*rac -1 python variable-assignment
这样做是否合法
a = b = 3
Run Code Online (Sandbox Code Playgroud)
在python?如果是这样,这是一种不好的做法吗?
是的,请注意这样的事情:
a = b = []
a.append(2)
print a
print b
Run Code Online (Sandbox Code Playgroud)
打印:
[2]
[2]
Run Code Online (Sandbox Code Playgroud)
但除此之外,没关系.@Martijn在他的回答中有很多信息,所以请查看:).