其他形式1:
1、定义函数
def test4(a = ()):
print('################test4################')
print(type(a))
print(a)
2、调用函数
正确调用:
test4((1, 2)) #a在函数体内部为tuple类型
test4(a=(1, 2)) #a在函数体内部为tuple类型
test4((1,)) #a在函数体内部为tuple类型
test4(a=(1,)) #a在函数体内部为tuple类型
test4((1)) #a在函数体内部为int类型,非tuple类型
test4(a=(1)) #a在函数体内部为int类型,非tuple类型
test4(1) #a在函数体内部为int类型,非tuple类型
test4(a=1) #a在函数体内部为int类型,非tuple类型
错误调用:
test4(1, 2) #TypeError: test4() takes at most 1 argument (2 given)
test4(1, b=2) #TypeError: test4() got an unexpected keyword argument 'b'
test4(a=1, b=2) #TypeError: test4() got an unexpected keyword argument 'b'