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.
如果我有如下功能:
def foo(): return 1, 2
我通常会这样调用函数:
g, f = foo()
但是,如果我从不打算使用返回的第二个值,有没有一种方法可以调用函数来说明这一点,所以将来我不会被占位符变量分心?
例如,类似:
g, not_used = foo()
似乎有一种标准的方法可以做到这一点。
您可以直接获取第一项:
g = foo()[0]
我认为pylint 建议_或dummy:
_
dummy
g, _ = foo()
我通常只要求我关心的值的索引