The nodal solutions of equations are considered to be more difficult than the positive solutions and the ground state solutions. Based on this, this paper intends to study nodal solutions for a kind of Schrödinger-Poisson equation. We consider a class of Schrödinger-Poisson equation with variable potential under weaker conditions in this paper. By introducing some new techniques and using truncated functional, Hardy inequality and Pohožaev identity, we obtain an existence result of a least energy sign-changing solution and a ground state solution for this kind of Schrödinger-Poisson equation. Moreover, the energy of the sign-changing solution is strictly greater than the ground state energy.