Today, let's learn why Python Lists and dictionaries are preceded by asterisks ()?**
what are you having? python I won't answer the related error report 、 Or source code information / Module installation /
Women's clothing bosses are proficient in skillsYou can come here :(https://jq.qq.com/?_wv=1027&k=2Q3YTfym) perhaps +V:python10010 Ask me
Python in , Single star * And the double star ** Except as “ ride ” and “ power ” Outside the numeric operator , Still on the list 、 Tuples 、 Dictionary plays an important role in the operation of .
The asterisk in front of the list is used to untie the list (unpacke) Into multiple independent parameters , Passing in functions .
def add(a, b):
return a + b
data = [7, 8]
print(add(*data)) # 15
python Learning exchange group :660193417###
import numpy as np
print(np.arange(3,6)) # [3 4 5]
list2 = [3, 6]
print(np.arange(*list2)) # [3 4 5]
Add two asterisks in front of the dictionary , Is to unpack the dictionary into independent elements as formal parameters .
def add(a, b):
return a + b
data = {
'a':7, 'b':8}
print(add(**data)) # 15
異常:原因: save()由於未保存的
# Definition for a binary tree