python的* 、**拆包(打散)功能

注:蟒蛇3

[En]

Note: python3

*示例

>>> a = (1,2,3)
>>> print(a)
(1, 2, 3)
>>> print(*a)
1 2 3
>>>
>>> b = [1,2,3]
>>> print(b)
[1, 2, 3]
>>> print(*b)
1 2 3
>>>
>>> c = "123"
>>> print(c)
123
>>> print(*c)
1 2 3
>>>
>>> d = {"a":1, "b":2, "c":3}
>>> print(*d)

**示例

>>> def func_dic(name, age):
...     print(name, age)
...

>>> func_dic(*dic)
name age
>>> func_dic(**dic)
张三20<details><summary>[En]</summary>Zhang San 20</details>

Original: https://www.cnblogs.com/kaituorensheng/p/15681723.html
Author: jihite
Title: python的*拆包(打散)功能

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/6372/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总