We consider a community detection problem for gossip dynamics with stubborn agents in this paper. It is assumed that the communication probability matrix for agent pairs has a block structure. More specifically, we assume that the network can be divided into two communities, and the communication probability of two agents depends on whether they are in the same community. Stability of the model is investigated, and expectation of stationary distribution is characterized, indicating under the block assumption, the stationary behaviors of agents in the same community are similar. It is also shown that agents in different communities display distinct behaviors if and only if state averages of stubborn agents in different communities are not identical. A community detection algorithm is then proposed to recover community structure and to estimate communication probability parameters. It is verified that the community detection part converges in finite time, and the parameter estimation part converges almost surely. Simulations are given to illustrate algorithm performance.