how can I select all objects in a collections using python?
If you want to process every object in a collection, you would have to iterate through Collection.all_objects:
collection = bpy.data.collections[&quot;collection_name&quot;]
for obj in collection.all_objects:
    print(obj.name) 

Further reading: How to list all collections and their objects?