Shawn's blog Shawn's blog
About Me
  • Category
  • Tag
  • Archive
GitHub (opens new window)

Shawn Jin

I am not a creator of knowledge, I am just a porter of knowledge.
About Me
  • Category
  • Tag
  • Archive
GitHub (opens new window)
  • Python

    • Python import files from different directories
    • Single/Double Star (*/**) Parameters in Python
      • Single Star Parameters
      • Double Star parameters
    • Classmethod in Python
    • Python modify range variable in for loop
  • Git

  • Notes
  • Python
Shawn Jin
2021-09-15

Single/Double Star (/*) Parameters in Python

# Difference between *Parameter and **Parameter in Python

They both represent unrestricted in number of parameters inputs.

# Single Star Parameters

Single Star Parameter would save parameters as tuple.

def fun1(para1, *para2):
    print(para1)
    print(para2)
>>> fun1(1,2,3,4,5)
1
(2,3,4,5)
1
2
3
4
5
6

# Double Star parameters

Double Star parameters would save parameters as dictionary.

def fun2(para1, *para2):
    print(para1)
    print(para2)
>>> fun2(1, a=2, c=3)
1
{'a': 2, 'c':3}
1
2
3
4
5
6
Updated: 2021/09/15, 21:07:45
Python import files from different directories
Classmethod in Python

← Python import files from different directories Classmethod in Python→

最近更新
01
Python import files from different directories
12-31
02
Classmethod in Python
09-15
03
Backprop Algorithm in Machine Learning
09-08
更多文章>
Theme by Vdoing | Copyright © 2019-2021 Shawn Jin | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式