Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果您熟悉 Matlab,则有一个全局变量ans,它捕获未分配给任何特定变量的函数的第一个返回值。Python中是否有任何匹配的构造?
ans
您正在寻找_:
_
>>> 1+1 2 >>> _ 2 >>> def f(x): ... return x+1 ... >>> f(3) 4 >>> _ 4