擅长:python、mysql、java
<p>我觉得他们应该使用<code>None</code>作为默认值。Python不是静态类型的,所以不需要^ {CD2}}是<EM> int eEM>(甚至静态类型的语言,比如C++)现在有选项类型),如果失败的话,它们可以使用^ {CD3}},这就不那么令人讨厌了。p>
<p>那么,至少他们为什么不使用<code>-1</code></p>
<p>一种可能性是,作者担心<code>-1</code>会被误解为“最后一个”。我发现<code>-100</code>是从Torch的Lua版本继承的。虽然在Lua中,<code>-1</code>通常并不表示“最后”,但Lua Torch的<code>Tensor</code>类<a href="https://github.com/torch/torch7/blob/master/doc/tensor.md" rel="nofollow noreferrer">used this convention</a></p>