import numpy as np
def chunks_with_numpy(numbers, chunk_size):
indices = np.arange(chunk_size, len(numbers), chunk_size)
return np.array_split(numbers, indices)
调用效果:
博学之、审问之、慎思之、明辨之、笃行之
import numpy as np
def chunks_with_numpy(numbers, chunk_size):
indices = np.arange(chunk_size, len(numbers), chunk_size)
return np.array_split(numbers, indices)
调用效果: