* Function usage

0904 self-summary

* Function usage

def fn(a, b, c, *, d=0, x):
    print(a)
    print(b)
    print(c)
    print(d)
    print(x)
fn(10, 20, 30, x=30, d=100)

Where * is the equivalent effect of a boundary, it is in front of the location parameter, followed by the key parameter

  • * Before positional parameters are: the location must be assigned no value, location may not have a value assigned, no value must be in position after
  • * After all keyword arguments: the keyword must be assigned no value, do not have value keywords can be assigned parameters are passed by name, so any order
  • * It can be followed by a variable to receive all of the positional parameters incompletely received

Guess you like

Origin www.cnblogs.com/pythonywy/p/11460993.html