Use the View Layer
From the context view layer
>>> C.view_layer.active_layer_collection
bpy.data.scenes['Scene']...LayerCollection
>>> C.view_layer.active_layer_collection.name
'My Leaf 0.0'
>>> C.view_layer.active_layer_collection.exclude
False
Alternatively from scene
>>> C.scene.view_layers['RenderLayer']view_layers['View Layer'].active_layer_collection
bpy.data.scenes['Scene']...LayerCollection
>>> C.scene.view_layers['RenderLayer']view_layers['View Layer'].active_layer_collection.name
'My Leaf 0.0'
>>> C.scene.view_layers['View Layer'].active_layer_collection.exclude = True
Related