#* positional arguments
#** keyword arguments
def testparameter(num, *tuples, **keywords):
print("num:", num)
print("tuples:")
for arg in tuples:
print(arg)
keys = sorted(keywords.keys())
for kw in keys:
print(kw, ":", keywords[kw])
if __name__ == "__main__":
#num: 3
#tuples:
#tuple1
#tuple2
#key1 : 1
#key2 : 2
testparameter(3, "tuple1", "tuple2", 10 , key1 = 1, key2 = 2)
<完>
本文详细介绍了如何使用Python的参数化函数,包括位置参数、关键字参数的应用,并通过实例展示了参数传递的灵活性。
1081

被折叠的 条评论
为什么被折叠?



