Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个看起来像的列表[[23,34],[43,23]],我想为每个数字添加一个 int 所以说如果我想向它添加 2 列表变为[[25,36],[45,25]]
[[23,34],[43,23]]
[[25,36],[45,25]]
>>> nums = [[23,34],[43,23]] >>> [[y + 2 for y in x] for x in nums] [[25, 36], [45, 25]]
麻木:
import numpy as np a = np.array([[23,34],[43,23]]) b = a + 2 #inplace: a += 2