>>> list(range(3,6))
[3, 4, 5]
>>> args = [3,6]
>>> list(range(args))
Traceback (most recent call last):
File "", line 1, in <module>
TypeError: 'list' object cannot be interpreted as an integer
>>> list(range(*args))
[3, 4, 5]
def people(name,age='0',sex='m'):
print(name,age,sex)
d = {'name':'slg','age':10,'sex':'f'}
people(**d)
运行结果
slg 10 f
def people(name,age='0',sex='m'):
print(name,age,sex)
d = {'name':'slg','age':10,'sex':'f'}
people(*d) #此处使用一个‘*’的是字典参数,看看会出现什么结果
运行结果
name age sex