I recently had a need to put the following python script together. In a nutshell, it will delete all objects in the configured pool_name matching the provided bucket_id:

#!/bin/python

import rados

bucket_id = "29e8cdca-0164-4aab-bf04-dea4178b6d85.204350.3"
pool_name = "default.rgw.buckets.data"

cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
cluster.connect()

ioctx = cluster.open_ioctx(pool_name)
objects = ioctx.list_objects()

for i in objects:
    if i.key.startswith(bucket_id, 0, len(bucket_id)):
#        print("removing object: " + i.key) # optional print
        ioctx.remove_object(i.key)

cluster.shutdown()
Caution: There is no undo here, please make sure you understand what is going to happen if you run this script.

For reference, an easy way to identify bucket_id is by querying the bucket metadata:

[root@tower-osd1 ceph-ansible]# radosgw-admin metadata get bucket:tenant1/testing

{
    "key": "bucket:tenant1/testing",
    "ver": {
        "tag": "_9u3ac2VqA_VEHugrSxe-Lpk",
        "ver": 1
    },
    "mtime": "2020-04-09 21:35:19.552974Z",
    "data": {
        "bucket": {
            "name": "wscnh-p",
            "marker": "29e8cdca-0164-4aab-bf04-dea4178b6d85.204350.3",
            "bucket_id": "29e8cdca-0164-4aab-bf04-dea4178b6d85.204350.3",
            "tenant": "tenant1",
            "explicit_placement": {
                "data_pool": "",
                "data_extra_pool": "",
                "index_pool": ""
            }
        },
        "owner": "tenant1$randy",
        "creation_time": "2020-04-09 21:35:19.525989Z",
        "linked": "true",
        "has_bucket_info": "false"
    }
}

Official Api Documentation: librados-python.