Copy header into new file astropy
问题 I have this script that makes a file with multiple extensions, but I would like to add headers from the old files to the extensions. new_hdul = fits.HDUList() new_hdul.append(fits.PrimaryHDU(header=headermain)) new_hdul.append(fits.ImageHDU(nod1, header=header1, name='Chop1')) new_hdul.append(fits.ImageHDU(nod2, header=header2, name='Chop2')) new_hdul.append(fits.ImageHDU(diff1, name='Dif')) Now I have tried: headermain = fits.getheader(file,0) and headermain = fits.open(file).header.copy()