Cloud computing is a computing service provided on demand through the Internet, which can provide sufficient computing resources for applications such as big data and the Internet of Things. Before using cloud computing resources, users need to lease the corresponding virtual machines in the data centers, and then submit the tasks to the leased virtual machines for execution. In these two stages, how to choose the optimal data center for resource deployment and task submission is particularly important for cloud users. To tackle the problem that it is difficult to select optimal data center to lease and use virtual machines in distributed data centers, we proposed data center selection algorithms based on deep reinforcement learning. In the stage of virtual machine lease, aiming to minimizing user costs, we considered both the cost of computing resources and the cost of network communication. Then, we used a deep enforcement learning algorithm to obtain the shortest communication path between the users and the data centers,and solve the problem of network communication costs which are difficult to calculate. We achieved an optimal selection of data centers and effectively reduce the overall user cost. In the stage of virtual machine use, to improve quality of service for the users, we use a deep reinforcement learning algorithm to obtain an optimal task scheduling strategy. This effectively solved the problem that user tasks cannot be effectively scheduled due to dynamic changes in the type and size of user tasks and in the state of the virtual machines. Moreover, the proposed scheme reduces the overall task completion time.