We report experimental evidence that a vortex in high-temperature superconductors (HTSC) traps a finite electric charge from the high-resolution measurements of the nuclear quadrupole frequencies. In slightly overdoped YBa2Cu3O7 the vortex is negatively charged by trapping electrons, while in underdoped YBa2Cu4O8 it is positively charged by expelling electrons. The sign of the trapped charge is opposite to the sign predicted by the conventional BCS theory. Moreover, in both materials, the deviation of the magnitude of charge from the theory is also significant. These unexpected features can be attributed to the electronic structure of the vortex in HTSC.