A horseshoe-shaped lock with a substantially C-shaped lock opening, comprising: a case comprising a lock body portion and side arm portions extending from left and right sides of the lock body portion respectively to form the substantially C-shaped lock opening; a battery compartment housing arranged inside the lock body portion, the battery compartment housing comprising a thin housing portion with a smaller thickness in the thickness direction of the lock body portion and a thick housing portion with a larger thickness in the thickness direction of the lock body portion, located in the left and right directions of the lock body portion; a lock pin provided with a retaining groove and configured to open or close a lock opening through movement thereof along a lock groove formed in the side arm portion; a tongue arranged on the outer surface of the battery compartment housing and configured to stop or release movement of the lock pin by entering or exiting from the retaining groove of the lock pin; a first force application member for exerting, on the lock pin, a force allowing the same to move in the direction of opening the locking opening; a second force application member for exerting, on the tongue, a force allowing the same to move in the direction of entering the retaining groove of the lock pin; a PCB accommodated in the battery compartment housing; a battery accommodated in the battery compartment housing and configured to provide electric power to respective electronic components in the horseshoe-shaped lock, wherein the battery and a part of the PCB are mounted in the thick housing portion of the battery compartment housing, and the other part of the PCB is located in the thin housing portion of the battery compartment housing; a motor arranged on the outer surface of the battery compartment housing; a motor driving module mounted on the PCB and configured to drive an output shaft of the motor to rotate; a tongue driving member connected to the output shaft of the motor and configured to convert a rotational driving force of the motor into a driving force allowing the tongue to move out of the retaining groove of the lock pin; and a location sensor arranged on the outer surface of the battery compartment housing and configured to detect whether the tongue is moved out of the retaining groove or not, wherein when the location sensor detects that the tongue is moved out of the retaining groove, the motor driving module stops driving the motor to rotate; wherein the PCB is mounted in the battery with a normal of its surface being substantially parallel to the front surface of the lock body potion; and the battery is substantially cuboid-shaped and is fixed in the thick housing portion of the battery compartment housing with its largest surface in the cuboid being substantially parallel to the surface of the PCB. a case comprising a lock body portion and side arm portions extending from left and right sides of the lock body portion respectively to form the substantially C-shaped lock opening; a battery compartment housing arranged inside the lock body portion, the battery compartment housing comprising a thin housing portion with a smaller thickness in the thickness direction of the lock body portion and a thick housing portion with a larger thickness in the thickness direction of the lock body portion, located in the left and right directions of the lock body portion; a lock pin provided with a retaining groove and configured to open or close a lock opening through movement thereof along a lock groove formed in the side arm portion; a tongue arranged on the outer surface of the battery compartment housing and configured to stop or release movement of the lock pin by entering or exiting from the retaining groove of the lock pin; a first force application member for exerting, on the lock pin, a force allowing the same to move in the direction of opening the locking opening; a second force application member for exerting, on the tongue, a force allowing the same to move in the direction of entering the retaining groove of the lock pin; a PCB accommodated in the battery compartment housing; a battery accommodated in the battery compartment housing and configured to provide electric power to respective electronic components in the horseshoe-shaped lock, wherein the battery and a part of the PCB are mounted in the thick housing portion of the battery compartment housing, and the other part of the PCB is located in the thin housing portion of the battery compartment housing; a motor arranged on the outer surface of the battery compartment housing; a motor driving module mounted on the PCB and configured to drive an output shaft of the motor to rotate; a tongue driving member connected to the output shaft of the motor and configured to convert a rotational driving force of the motor into a driving force allowing the tongue to move out of the retaining groove of the lock pin; and a location sensor arranged on the outer surface of the battery compartment housing and configured to detect whether the tongue is moved out of the retaining groove or not, wherein when the location sensor detects that the tongue is moved out of the retaining groove, the motor driving module stops driving the motor to rotate; wherein the PCB is mounted in the battery with a normal of its surface being substantially parallel to the front surface of the lock body potion; and the battery is substantially cuboid-shaped and is fixed in the thick housing portion of the battery compartment housing with its largest surface in the cuboid being substantially parallel to the surface of the PCB.