Calculations of electronic structure for clusters ThO610-, UO610-, ThO812-, and UO812- in thorium and uranium mono- and dioxides have been carried out, in the one-electron local density approximation. Spin polarization and relativistic effects are studied. Energy level diagrams, charge and spin densities, and electronic configurations of metal atoms have been obtained. It is shown that for the valence levels, relativistic splittings are quite small, but they are very essential for describing metal 6p levels. Chemical bonding effects in thorium and uranium oxides are studied. It is shown that 5f metal orbitals significantly hybridize with ligands and take part in chemical bonding. Strong hybridization of 5f and 6p metal orbitals also takes place. The MO diagrams obtained are compared with the experimental X-ray photoelectron spectra of UO2 and ThO2, and with optical spectra of UO2. Calculations of XPS line shapes have been carried out; the calculated results agree well with experiment.