How to access to pivot location? I just want to get the pivot location of the 3d model!

I tried to set the cursor to pivot position and print the cursor location
import bpy

bpy.ops.view3d.snap_cursor_to_selected()
print(bpy.context.scene.cursor.location)

I had this error:
RuntimeError: Operator bpy.ops.view3d.snap_cursor_to_selected.poll() failed, context is incorrect
Error: Python script failed, check the message in the system console
Objects pivot around their origins, or (0, 0, 0) in their local space. An object's position is simply the location of its origin in world space. You can get this as a Vector from the object's location variable:
import bpy

obj = bpy.context.active_object
print(obj.location)

If you actually did want to set the cursor location:
bpy.context.scene.cursor.location = obj.location

See How do you get an object&#39;s position and rotation through script? for a more thorough look.