We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8288114 commit 4782217Copy full SHA for 4782217
args_unpacking.py
@@ -0,0 +1,13 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# 使用tupple或dict传参的技巧
4
5
+def product(a, b):
6
+ print(str(a) + '*' + str(b))
7
+ return a * b
8
9
+argument_tuple = (1, 1)
10
+argument_dict = {'a': 1, 'b': 1}
11
12
+print(product(*argument_tuple)) # 这里用*解析tupple类型的变量作为product的参数
13
+print(product(**{'b':4,'a':3})) # 这里用**解析dict类型的变量作为product的参数
0 commit comments