How to save dicom image or segmentation mask to a .py file or .nii file?

I used the “segment editor” to get the bone tissue just now. and then I need save the segmentation mask to a .py file. I did not find how to do it in GUI, so I tried to do it with python script.I tried to get the data from node and save the numpy array to .py file. but i found seems there is not data array in the saved file. here is the python code :
import numpy as np
bone_arr = np.array(‘Segment_1’)#Segment_1 is the bone mask‘d:\test.npy’,bone_arr)
And then I tried to use “savenode” save the segmentation node to .py file. But I failed, seems the node can not be saved as .py file. And I do not know how to get the data array (segmentation)from the node easily in python script.Or can i save the segmentation mask to the .nii or .py file in GUI?
thank you in advance.

You need to export to a labelmap first, which you can do in the Segmentations module panel shown below. Then you can do:

>>> a = array("Segmentation-label")
>>>'/tmp/', a)


Your answer works. Thanks a lot.