A woman has fought off a five-metre-long Burmese python by using a pocket knife to free her pet dog from its grip, the South China Morning Post has reported.

Courtney Link, a British expatriate who lives in Sai Kung, Hong Kong, stabbed the snake several times until it released its hold on Dexter, her defenceless pooch.

The attack occurred in Sai Kung West Country Park where Link and her husband were walking their dog.

While they were strolling, Dexter ran out of sight.

The couple found the dog in the deadly grip of a huge python, coiled around its body.

"I immediately began to pummel the snake with my fists, but to no avail," said Link.

Her husband remembered he had packed his pocket knife and pulled it from his backpack.

"Dexter was starting to weaken and he eventually stopped struggling altogether. At that point we really thought we had lost him. So when I suddenly saw the snake's head, I just started stabbing furiously," Link said. "Apart from some nasty bite wounds to his chest and legs, Dexter has made a complete recovery and he is back to his exuberant and hyper self.

"I deeply regret I had to seriously injure a protected animal, but I acted only to save the life of my dog," Link concluded.

A spokeswoman for the Agriculture, Fisheries and Conservation Department confirmed Link had reported the python attack.

In general, pythons are unlikely to attack unless provoked, she said, but warned that people with pets should try to avoid areas where pythons tend to prowl for food and shelter, such as dense vegetation.

The Burmese python is Hong Kong's biggest natural predator and can grow up to six metres long.

The reptile is rarely sighted but Burmese python attacks on dogs are not unknown, China.org said.

In 2007, a woman rescued her pet dog following a fight with a 4.5-metre python and the previous year a 22-kilogramme husky was crushed to death by a snake.