程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python adds an asterisk * before the array of lists, elements, dictionaries, sets and numpy (the return container in the \u make\u layer function in RESNET is marked with an asterisk)

編輯:Python

python In the list 、 Elements 、 Dictionaries 、 The collection and numpy Add an asterisk to the array of * The meaning of

stay resnet Medium _make_layer Last in function return nn.Sequential(*layers) With an asterisk :

Example :

List = ['a', 2, 3]
Tuple = ('b', 'c', 5)
Dict = {
'name': 'Ada', 'age': 23}
print(List)
print(Tuple)
print(Dict)
print(*List)
print(*Tuple)
print(*Dict)
import numpy as np
ndarray = np.array([2, 3, 4])
print(ndarray)
print(*ndarray)
##################################
# The output is as follows :
'''
['a', 2, 3]
('b', 'c', 5)
{
'name': 'Ada', 'age': 23}
{
2, 4, 5}
a 2 3
b c 5
name age
2 4 5
[2 3 4]
2 3 4
'''

As can be seen from the above : In the list 、 Tuples 、 Dictionaries 、 aggregate 、 Array preceded by *, The printed output shows that , The elements in these data structures are divided into independent elements one by one .
Reprinted from :python In the list 、 Elements 、 Dictionaries 、 The collection and numpy Add an asterisk to the array of * What does it mean , as well as *args and **kwargs Use


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved