Photoelectrocatalysis (PEC) system has been proven to be effective in degrading perfluorooctanoic acid (PFOA) and generating electricity as a goal to solve the problems of environmental pollution and energy shortages simultaneously. In this study, we utilized a flower-like WO3in-situ generated on tungsten foil (WO3/W), and then doped with a CN layer by immersing it in urea solution and then undergoing calcination (CN-WO3/W), to degrade PFOA and generate electricity. The growth mechanism of WO3/W with different morphologies prepared under various experimental conditions was analyzed in order to explain the reasons for the superior performance of the flower-like structure compared to other morphologies. Under the irradiation of simulated sun-light, the power density reached its peak at 0.11 mW/cm2 when current density was 0.14 mA/cm2 with PFOA as fuel. CN-WO3/W displayed a steady state photocurrent density of 6.1 mA/cm2 at 1.2 V (vs. Ag/AgCl) under simulated sun-light irradiation and a high PFOA degradation of 95 %, which is much higher than that of WO3/W. Due to distinctive flower-like structure, stable W–N–C bond, narrower energy band (from 2.67 to 2.41 eV), more acquisition of visible light, and strong oxidation capability, the CN-WO3/W exhibited high stability and reusability for simultaneous PEC degradation of PFOA (almost unchanged after 9 cycles) and electricity generation (without activity loss during the 24 h test) under simulated sun-light irradiation. Based on the scavenger-quenching experiments the possible degradation pathways of PFOA were suggested. This work provides a way to design and synthesize the photoanode to construct reaction system for high-performance photocatalytic PFOA degradation and electricity generation.