- 关键字参数
- 默认参数
- 不定长参数
def print_info(name, age, sex="Male"):
print("Name={}, Age={}, Sex={}".format(name, age, sex))
print_info('Ruby', 30) # 必须字参数
print_info(name='Ruby', age=30) # 关键字参数
print_info('Kevin', 36, 'Female') # 默认参数
# print_info('Kevin', 36, 'Female','IT')
def add(*args):
sum = 0
for num in args:
sum += num
print(sum)
return sum
print(id(add))
add(2, 3, 1, 4) #不定长参数