Bernie Sanders likes to tub-thump about “the millionaires and the billionaires” — but oops, it turns out he is one of them now.

Last week, the Vermont socialist and presidential contender said he would release his tax returns, and, side note, he is super rich. But don’t worry, Sanders reassured his legions of hard-left fanatics, he isn’t like those other rich people.

“I wrote a best-selling book,” he said. “If you write a best-selling book, you can be a millionaire, too.” Put another way, the good comrade ­explained how easy it can be to make a lot of money in a capitalist economy like ours.

Of course, he is exactly like other wealthy Americans: You provide a service or produce something people want to buy, and you go from ­disheveled lawmaker from Vermont to millionaire disheveled lawmaker from Vermont.

Only in America!

Other millionaires and billionaires can explain their riches like Bernie does. “I started a website that sold books, and now we sell everything.” “I invented a way to search the internet with ease and accuracy.” “I invested in companies and helped them grow.” “I run a pharmaceutical company that cures diseases and produces medication so sick people can live better lives.”

Bernie’s book-writing, in other words, isn’t any nobler than the paths taken by other millionaires.

His campaign manager, Faiz Shakir, offered up this word salad for why it’s OK that Bernie is rich while attacking the system that made him rich: Sanders “believes in opportunity for all, and the fact that he is somebody who has personally benefited from that ­opportunity is something that he feels should be a shared opportunity with everyone else. He’s made some money off a book. And I think that the opportunity that he has had is evaporating for so many others. He feels that strongly.”

He had the opportunity, wants to share the opportunity, the ­opportunity is evaporating. Got it.

Bernie is, of course, not the first person to use this “my wealth good, your wealth bad” line while attacking other rich people.

During the Occupy Wall Street protests in 2011, Michael Moore posted a screed to his website defending his being in the 1 percent while railing against capitalism. No, you see, he didn’t make his money via capitalism. He made his money by making films and selling these — which is somehow completely different than how other capitalists do it. “I make my money the old school, honest way by making things,” he wrote with no hint of irony or introspection.

Closer to home, Mayor Bill de Blasio likes to repeat that “the money is in the wrong hands.” The creepy refrain is often accompanied by the idea that the mayor knows exactly “where it is.”

We all know where it is: The mayor who owns a $2 million dollar house in Park Slope has it! This is the great promise of America: A guy who takes a motorcade to ­another borough to work out at his preferred gym has the gall to lecture the rest of us on being too wealthy. You can be anything in this great land, even a really rich guy criticizing other people for being rich.

Also last week, Liz Warren, ­another senator and Dem presidential contender, released her taxes and disclosed that she, too, is rolling in it. Warren and her husband cleared nearly a million dollars last year. Yet the happy couple didn’t voluntarily pay the wealth tax that Warren is proposing for other rich people.

Sure, Warren’s tax would only be on the super-rich, not merely the extremely rich like Warren herself, but she can easily get the ball rolling on her proposal by dispatching 2 percent of her income to Uncle Sam. Show the rest of us how it’s done, Liz!

There’s nothing wrong with ­being rich. It would just be nice if rich liberals acknowledged that. Instead, Sanders, Warren, Moore and de Blasio all push the same wealth- redistribution policies while hoarding their own wealth.

These politicos’ terrible opinions shouldn’t be discounted just ­because they are rich, to be sure, but the fact that they don’t walk the walk should give their fans pause. Capitalism is a powerful engine for social mobility, and prosperous capitalists like Bernie Sanders should have the courage to say so.