PRAGUE — In the age of Amazon and the internet, the idea of going to a public library to borrow a book may seem ever more quaint and old-fashioned in many parts of the world, but one country, at least, is clinging to it tenaciously: the Czech Republic.

There are libraries everywhere you look in the country — it has the densest library network in the world, according to a survey conducted for the Bill and Melinda Gates Foundation. There are more libraries than grammar schools. In fact, there is one library for every 1,971 Czech citizens, the survey found — four times as many, relative to population, as the average European country, and 10 times as many as the United States, which has one for every 19,583 people.

Why so many Czech libraries? Well, for decades they were mandatory — every community, from a big city down to a tiny village, was required by law to have one.

The law was enacted in 1919, soon after Czechoslovakia emerged as an independent country. The idea was to promote universal literacy and education after the country was free of the German-speaking Austro-Hungarian Empire. And it worked.