Python script to load and output DICOM

Hello, I try to write a python script to do elastix registration in a batch (loop through many subjects). Could you please share some python script to load DICOM series from a folder and Output the volume to DICOM as well? Thank you!