Extracting the a value from a tuple when the other values are unused

前端 未结 6 1289
一整个雨季
一整个雨季 2021-02-04 10:42

I have a tuple foo which contains something I don\'t care about and something I do.

foo = (something_i_dont_need, something_i_need)
<
6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 10:49

    1st case: foo needs two variable to unpack (length of tuple is 2) . _ is perfectly ok.

    2nd case: gives you index value (slicing)

提交回复
热议问题