How do astronomers know whether they are seeing planets or stars when they are distant?

"Twinkle, twinkle little star," but that is unlikely with planets. Also planets rotate in contrast to stars.