The code snippet below will get all layers in a .dxf AutoCAD file and print them on the console. It use the ezdxf module which you can install using pip.
import ezdxf
dwg = ezdxf.readfile('file_name.dxf')
for layer in dwg.layers:
print (layer.dxf.name)