The utility model discloses a lock capable of being mechanically unlocked and electronically unlocked. The utility model aims to solve the problem that when a lock in the prior art is provided for an unspecified user to use or is shared by a plurality of people, a user who is used as an electric lock or a mechanical lock is inconvenient to use. According to the technical scheme, the lock comprises a lock shell, a lock cylinder, a lock cylinder driving gear, a driving rod and a lock rod and is characterized by further comprising a motor driver and a sliding push block, the lock rod is composed of a lock rod front section, a lock rod rear section and a compressed spring, the lock rod front section and the lock rod rear section are in sliding fit with the lock shell, a long hole sliding groove is formed in the lock rod rear section, and a spring sleeve rod is arranged at the position, on the rear side of the long hole sliding groove, of the lock rod rear section; a protruding lock rod sliding block and a pushed plate are arranged on the front section of the lock rod, the lock rod sliding block is arranged in the long hole sliding groove in a sliding fit mode, the spring sleeve rod is sleeved with the compressed spring and abuts against the lock rod sliding block, the motor driver is fixed to the lock shell, the sliding pushing block is arranged on the lock shell in a sliding fit mode, and a driving lead screw on the motor driver is in threaded fit with the sliding pushing block. And the sliding push block is in pushing fit with a pushed plate at the front section of the lock rod.