36 lines
471 B
Python
36 lines
471 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
@File : 拆包.py
|
|
@Author : lichao
|
|
@Date : 2024/12/11 16:49
|
|
@Software : PyCharm
|
|
"""
|
|
|
|
|
|
def fn_1():
|
|
return 1, 2, 3
|
|
|
|
|
|
num1, num2, num3 = fn_1()
|
|
print(num1, num2, num3)
|
|
|
|
nums = [11, 22, 33]
|
|
|
|
|
|
def test_fn(a, b, c):
|
|
print(a, b, c)
|
|
|
|
|
|
# 拆包
|
|
test_fn(*nums)
|
|
|
|
|
|
def test_fn1(name, age, add):
|
|
print(name, age, add)
|
|
|
|
|
|
# 拆包字典
|
|
info = {"name": "lc", "age": 22, "add": "beijing"}
|
|
test_fn1(**info)
|