When ball pythons do this, it usually means that they want to get out. There's something wrong with their husbandry that is making them want to escape, and they do it mostly out of stress. Check your temps and humidity. See if it's off from where it should be.
Mine is probably doing it out of humidity. But that was fixed yesterday![]()