Depends on if it's a baby or an adult. If it's a baby, it's just terrified, and will outgrow the behaviour with gentle handling. Even minimal gentle handling, like weighing and feeding in a deli cup every 5-7 days.
If it's an adult, is it biting because it's hungry, or defensive? If it's hungry, I get the snake out with a hook before EVER starting to thaw mice, and place it in its feeding container. When replacing the snake after feeding, I let it settle for a while to get out of feeding mode. I get the snake moving by tilting the feeding container before sticking my hand in, or just pour the snake back into its bin.
If the snake is defensive, when removing the snake, I try to not surprise it. If it's asleep in a hide, I tap on the hide first so the snake wakes up- I don't just grab it. If the snake is awake, I try to reach in and just pick it up without hesitation, mid-body. If the snake is moving, it's most likely not going to bite. If the snake is coiled up in a strike position, sometimes you can put your hand down flat on top of it. Or, you can just hook the front of the snake with a hook and pick up the mid-body with your other hand. Usually by the time the snake is out, it isn't going to bite.
Very rarely you will encounter a snake that just doesn't want to be handled at all. I've found that no amount of "taming" will make that snake enjoy it. I still feed the snake out of the viv, and weigh at every feeding, just so it doesn't become completely intractable, but I respect its wishes to be left alone, otherwise.
I've only had one snake that was so bitey and miserable to handle that I sold him- Mr. Ruby. He was sold to me as a female, and his genes were redundant. So- even though he was one of the prettiest bloodred stripes ever, one day he bit me and it was one bite too many and I advertised him for sale and he was gone in five minutes. That person still has him!
But sometimes, the snake just doesn't like _you_. Mr. Ruby, mentioned above, also did not like his new owner, but he _does_ like her significant other, who can handle him without getting bitten.
My response, if I get bit, is to just ignore the behaviour. Take a photo of the wound for bite club. Adminster the antidote! ;-) If the snake is hanging on, try to get a photograph. I typically keep the snake out until it overcomes its fear and relaxes, and put it away or put it in its feeding bin on a positive note.