0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonの返り値での "*_ " の意味

Posted at

恥ずかしながら返り値を受け取るところでスターを使えることを知らなかったので…

*a, b = list(range(5))
print(a)
# -> [0, 1, 2, 3]
print(b)
# -> [4]

つまり,返り値(戻り値)を受け取る変数の冒頭に*(star演算子,アスタリスク)をつけるとその変数はリストになり,可変長個の返り値を受け取れる.*_ は捨てる返り値を可変長個受け取るという意味のことが多いだろう.

0
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?