When it comes to space, the word eccentricity nearly always refers to orbital eccentricity, or the eccentricity of the orbit of an astronomical body, like a planet, star, or moon. In turn, this relies on a mathematical description, or summary, of the body’s orbit, assuming Newtonian gravity (or something very close to it). Such orbits are approximately elliptical in shape, and a key parameter describing the ellipse is its eccentricity.
In simple terms, a circular orbit has an eccentricity of zero, and a parabolic or radial orbit an eccentricity of 1 (if the orbit is hyperbolic, its eccentricity is greater than 1); of course, if the eccentricity is 1 or greater, the ‘orbit’ is a bit of a misnomer!
In a planetary system with more than one planet (or for a planet with more than one moon, or a multiple star system other than a binary), orbits are only approximately elliptical, because each planet has a gravitational pull on every other one, and these accelerations produce non-elliptical orbits. And modeling orbits assuming the theory of general relativity describes gravity also leads to orbits which are only approximately elliptical (this is particular so for binary pulsars).
Nonetheless, orbits are nearly always summarized as ellipses, with eccentricity as one of the key orbital parameters. Why? Because this is very convenient, and because deviations from ellipses can be easily described by small perturbations.
The formula for eccentricity, in a two-body system under Newtonian gravity, is relatively easy to write, but, unfortunately, beyond the capabilities of the HTML coding of this webpage.
However, if you know the maximum distance of a body, from the center of mass – the apoapsis (apohelion, for solar system planets), ra – and the minimum such distance – the periapsis (perihelion), rp – then the eccentricity, e, of the orbit is just:
E = (ra – rp)/( ra+ rp)