list列表乘法:列表list*n = 列表list内所有元素添加n次
list列表加法:相当于append()函数
PyDev console: starting.
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
x = []
x.extend(["wo"]*3)
x
['wo', 'wo', 'wo']
# 乘法?yes!
["wo"]*3
['wo', 'wo', 'wo']
# 加法?yes!相当于append
["wo"]+["1"]
['wo', '1']
# 减法?失败hhh
["wo"]-["1"]
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'list' and 'list'
["wo","1"]-["1"]
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'list' and 'list'