复制代码def drem(x, y): """Like fmod but rounds to nearest integer instead of floor.""" xd = decimal.Decimal(x) yd = decimal.Decimal(y) return float(xd.remainder_near(yd))