There's not a lot of built-in support for operations on degrees (Vector math is the generally supported way of doing these kinds of things).
This function should do the trick:
# returns the difference (in degrees) between angle1 and angle 2
# the given angles must be in the range [0, 360)
# the returned value is in the range (-180, 180]
def angle_difference(angle1, angle2):
var diff = angle2 - angle1
return diff if abs(diff) < 180 else diff + (360 * -sign(diff))