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

[Python] Summary and Summary of the Usage of Operators Plum Blossom* and Multiplication*

編輯:Python

One, repeat n times and expand n times

tuple | list | string, repeating n times

Array, which means that each element is multiplied by n

import numpy as nparr = np.array([1, ])print(arr*3)list1 = [1, ]print(list1*3)tuple1 = (1, )print(tuple1*3)str1 = "python"print(str1*3)#[3]# [1, 1, 1]# (1, 1, 1)# pythonpythonpython

Second, unpacking

I have written several application cases about using the plum blossom* to unpack

python-The operator * is used for scenario analysis of unpacking - repeating modules

The above article describes how to use the unpacking operation to insert an element multiple times at a certain position in a list.

python-* unpacking and the application of the zip function, the return value of the zip function itself cannot be unpacked with *

The above article talks about the combination of the zip function and the unpacking mechanism.

python-deduction can directly pass in function parameters, deduction and the unpacking usage of the * (asterisk) operator

The above article describes how to use the derivation and unpacking mechanism to directly use the derivation as a function parameter.

*Unpacking can be done on almost all iterable objects.; It can be understood colloquially as opening the "bag" to facilitate "taking things" from it.


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