Python的序列解包

tech2026-06-09  4

Python的序列解包是一种语法糖,很实用,在函数返回多个值的时候使用尤为方便

def test_two_res(): n = 2 m = 3 return n,m n,m = test_two_res() print(n,m) #2 3 n,m,*c = "zhangsan" print(n,m,c) #z h ['a', 'n', 'g', 's', 'a', 'n']

 

最新回复(0)