Python mostly uses reference counts for garbage collection. To do this each object has a field counting the number of references that are pointing to it. When a reference is copies, the count is increased by one. When a reference is released (goes out of scope) the count is decreased by one. If it reaches zero, the object is no longer needed and the memory is released.
In addition, it has a garbage collector like Java that searches for reachable objects. This is required because circular data structures can't be released by the reference counting mechanism.