如何用0填充所有边上的numpy数组

时间:2018-04-08 15:26:52

标签: python arrays numpy

如何在所有四个边上用0填充2D numpy数组。

a = np.array([(1, 2, 3),(4, 5, 6)])

1 个答案:

答案 0 :(得分:0)

如上所述,您可以使用numpy.pad

您可以使用import net.minecraft.init.Blocks; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import org.apache.logging.log4j.Logger; @Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION) public class Main { public static final String MODID = "immersivesignals"; public static final String NAME = "Immersive Signals"; public static final String VERSION = "1.0"; @SidedProxy(clientSide = "com.elitedire4k.immersivesignals.ClientProxy", serverSide = "com.elitedire4k.immersivesignals.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerItem(BufferItem.instance); GameRegistry.registerBlock(BufferBlock.instance); proxy.preInit(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.preInit(); } } pad_width=1。您可以添加mode='constant',但由于constant_values=0是默认值,因此不需要这样做。

0