A printer with print head cleaning function is provided. The printer includes a housing, a round shaft, a carrier and a clean housing. The round shaft is disposed in the housing. The carrier is reciprocally disposed on the round shaft. The carrier is used for carrying one cartridge of the printer. The clean housing is equipped with a cleaner, which is used for cleaning one print head of the cartridge. When the carrier moves upward or downward, the carrier mechanically drives the clean housing to move upward or downward to maintain a fixed interference distance between the cleaner and the print head for enabling the cleaner to clean the print head and maintain the printing quality.