0
0

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 1 year has passed since last update.

pythonのアンパック演算子のメモ

Last updated at Posted at 2022-10-24

Dictの中身を*演算子をつかって操作する方法について、アンパックの動きをメモ

test = {'aaa': [0, 2], 'bbb': [1, 3]}
print(*test)
print(test.values())
print(*test.values())
testv = [t for t in zip(*test.values())]

for x, y in zip(test, testv):
  print(x, y)
aaa bbb
dict_values([[0, 2], [1, 3]])
[0, 2] [1, 3]
aaa (0, 1)
bbb (2, 3)

となる

参考になりそうな記事:
https://python.keicode.com/lang/list-unpack-asterisk.php

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?