I have a king snake that does that. Most of the time he's just grumpy but I guess it could be from excitement too. He does it every time we pull him out of his tank and after we put him back in from a feeding. I chalk it up to him being grumpy. I did read that they do that in the wild as a defense mechanism, it rattles the leaves or something.