How can I animate data using blender python?
You just need to change your keyframe statements:

ob1.keyframe_insert(data_path = "rotation_euler", index = -1)
ob2.keyframe_insert(data_path = "rotation_euler", index = -1)