Just set the spines (and/or ticks) to be invisible.
E.g.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.show()
If you want to hide the ticks on the top and left as well, just do:
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')