Houdini the Burmese python gave his owner a shock after swallowing a queen-size electric blanket, including the electrical cord and control box.
X-rays showed the blanket's wires running through 8ft of the python's 12ft (3.6m) body and emergency surgery was needed to remove them.
Owner Karl Beznoska, of Ketchum in Idaho, US, believes the blanket become entangled in Houdini's rabbit dinner.
Vets say it would have taken the python six hours to swallow the blanket.
They believe 18-year-old Houdini would have died had they not performed the two-hour operation.
The vet who carried out the surgery, Karsten Fostvedt, said the "prognosis is great". Houdini is now recovering.
Neither Mr Fostvedt nor his colleague at Ketchum's St Francis Pet Clinic had operated on a snake before and had to telephone two specialists for advice after Houdini was brought in.
Mr Beznoska told the Idaho Mountain Express newspaper that he noticed Houdini was not looking well on Monday morning - and the blanket kept in his cage for warmth had disappeared.
He said the blanket must have got caught up in Houdini's rabbit dinner on Sunday, and the python continued to gulp down the blanket even after his food had gone.
"This is something I've never heard of or seen before," he said.
Mr Beznoska has had Houdini for 16 years and calls him "a good boy" and "very mellow and very friendly".
The 60lb (27kg) python is apparently something of a local celebrity, and a popular visitor to schools and libraries.