This paper presents a community gas-safety risk-prediction method for solving the complex and continuous community gas-safety factors based on the temporal knowledge graphs. First, a community gas-safety risk-assessment index system is constructed based on the risk sources and factors influencing gas accidents. Entity and relationship features are extracted from the index system to construct a temporal knowledge graph of the community gas system. The community gas-safety risk-assessment index system is constructed based on the risk sources and risk-influencing factors of gas accidents. Furthermore, entity and relationship features are extracted in the index system to construct temporal knowledge graphs for a community gas system. Then, a gas-system risk-prediction method based on the temporal knowledge graphs is proposed, which predicts the risk level of the gas system in a certain period in the future. Finally, by applying the method in a specific community, the accuracy of the proposed prediction method is 74.87%, and the mean reciprocal rank is 87.44. The proposed gas-safety risk-prediction method based on a temporal knowledge graph network can assist managers in effectively managing community gas and has a positive auxiliary effect on sensing and controlling gas-safety situations.