A method for measuring the mechanical parameters of viscoelastic polymers by nanoindentation technology was proposed and verified. Through the mechanical response of load-displacement curves at different loading rates, then creep compliances and relaxation modulus were fitted. Polyimide thin film was employed in this research and experiments for five different loading rates were conducted. The fitting load-displacement loading curves obtained by the inversion method were identical to the experimental curves at five different loading rates,confirming the validity of the method. Moreover, with the loading rates increased,the fitting curves were more consistent commensurately with the nanoindentation experiment. DMA experiments were tested, and the generalized Kelvin/ Maxwell model were used for fitting experiment data. Results from DMA tests generally agree well with data from nanoindentation method, thereby verifying the feasibility of the method. The Prony series obtained by the two methods were used to simulate the creep experiments, which further verified the method.