Skip to content

Commit 79d0b5a

Browse files
committed
Update README.md
1 parent 314929a commit 79d0b5a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

python/python-basic/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,30 @@ def print_name_in_3rd_module():
419419

420420
> 这部分的内容的组织方式自参考了文章[2]
421421
422+
## 其他
423+
424+
### Python 参数传递
425+
426+
Python函数参数前面单星号(*)和双星号(**)的区别
427+
428+
```python
429+
'''单星号(*):*agrs:将所以参数以元组(tuple)的形式导入'''
430+
def foo(param1, *param2):
431+
print(param1, param2)
432+
433+
'''双星号(**):**kwargs:将参数以字典的形式导入'''
434+
def bar(param1, **param2):
435+
print(param1, param2)
436+
437+
foo(1,2,3,4,5)
438+
# output: 1 (2, 3, 4, 5)
439+
440+
bar(1,a=2,b=3)
441+
# output: 1 {'a': 2, 'b': 3}
442+
```
443+
444+
445+
422446
## Reference
423447

424448
1. [Python 3 官方文档](https://docs.python.org/zh-cn/3/)

0 commit comments

Comments
 (0)