The embodiment of the invention provides a dynamic calculation unloading and resource allocation method and device based on Q learning, and the method comprises the steps: calculating the total calculation resources of an MEC server based on the calculation task parameters of UE, the performance parameters of the UE, the channel parameters between the UE and an AP, and the mobile edge, and constructing an optimization problem model; and determining the optimal solution of the optimization problem model based on Q learning, wherein the optimal solution comprises an unloading decision of the UE,a percentage of computing resources allocated to the UE by the MEC server, and a percentage of spectrum resources allocated to the UE by the AP. According to the calculation unloading and resource allocation method and device based on Q learning provided by the embodiment of the invention, and meanwhile, the actual calculation unloading and resource allocation characteristics in the time-varyingMEC system are considered, the delay threshold of the task and the limited resource capacity constraint of the system, and the joint optimal scheme of calculation unloading and resource allocation based on Q learning is determined, thereby further reducing the energy consumption of the UE.