import bpy
# コレクションを作成
collection_name = "SphereCollection"
if collection_name not in bpy.data.collections:
sphere_collection = bpy.data.collections.new(collection_name)
bpy.context.scene.collection.children.link(sphere_collection)
else:
sphere_collection = bpy.data.collections[collection_name]