The snake usually constricts the person or animal until they die by suffocation, due to an inability to expand the lungs. There have been cases where they eat living creatures, including people, but suffocation is pretty guaranteed once they swallow the head.
When I was growing up in Jakarta, they found two enormous pythons in the culvert right next to the elementary school. They sacrificed a goat to lure them out, then when they were dated they just packed them up and took them to a local safari park. The smaller one was about 21 feet long, while the bigger one was 24 or 25. Just huge.
I dunno what would be a better attempt at self defense against such large snakes, but I think I'd start carrying around both pepper spray and also a stun gun, just in case.
No idea if either would be fully effective, but damn that would be a hell of a way to go, might as well try to be prepared to defend myself.
I used to use rubbing alcohol on my pet snake's nose if he accidentally latched onto me instead of his food. I don't have any idea if that would work on snakes that kill by constriction though
In that case, I'd probably carry around a super soaker water gun loaded with some strong alcohol, and just hope I'd be able to shoot it at a distance before it gets close enough to wrap around me.
Could also in a pinch light the alcohol on fire as a crude flamethrower, packing a double punch...
I'm assuming the person has at least one hand free. A big "that's not a noife, this is a noife" would solve the problem lickety split. If both arms are pinned then there isn't much you can do. Try to bite it I guess, but they're used to being bitten by animals much more ferocious than humans.