The development of smart technology and smart cities has solved the problem of data islands, but it has also brought about information security problems. Federated learning provides solutions to information security problems, which is a new machine learning method that effectively protects the local privacy of edge devices by distributing models to edge devices for training. However, due to malicious attacks from malicious edge devices, the accuracy and efficiency of federated learning are greatly compromised. Therefore, to solve the above problems, this paper proposes a reputation-aware method based on reinforcement learning (RA-RL) to select edge devices to ensure that the federated learning process is not attacked. Specifically, we introduce a reputation measurement scheme to evaluate the reputation of edge devices and use it as one of the features of edge devices. Then extract the feature matrix of candidate edge devices as the RL training environment to calculate the probability of each edge device is selected, and finally use the greedy algorithm to determine the devices that will eventually participate in the federated learning. Simulation experiments show that the RA-RL algorithm can effectively solve the training data security problem in federated learning, and is superior to other algorithms in terms of load balance, efficiency and accuracy.