Nuclear magnetic resonance (NMR) of 31 P and 51 V nuclei has been measured in a spin-1/2 alternating-chain compound (VO)2P2O7. By analyzing the temperature variation of the 31 P NMR spectra, we have found that (VO)2P2O7 has two independent spin components with different spingap energies. The spin gaps are determined from the temperature dependence of the shifts at 31 P and 51 V sites to be 35 K and 68 K, which are in excellent agreement with those observed in the recent inelastic neutron scattering experiments [A.W. Garrett et al., Phys. Rev. Lett. 79, 745 (1997)]. This suggests that (VO)2P2O7 is composed of two magnetic subsystems showing distinct magnetic excitations, which are associated with the two crystallographically-inequivalent V chains running along the b axis. The difference of the spin-gap energies between the chains is attributed to the small differences in the V-V distances, which may result in the different exchange alternation in each magnetic chain. The exchange interactions in each alternating chain are estimated and are discussed based on the empirical relation between the exchange interaction and the interatomic distance.