In this study, a flexible strain sensor based on nanocomposites filled with three-dimensional carbon nanotube (CNT) foam was developed. CNT sample was prepared by using melamine-formaldehyde foam as a template, and the prepared material showed hydrophobic properties and the ability to spontaneously adsorb uncured polymer (polydimethylsiloxane) with excellent structural stability, thus ultimately eliminating the problems associated with the dispersion and re-agglomeration of CNTs in a polymer matrix. The flexible nanocomposite sensor showed excellent piezoresistivity under both compression and tension strain with high sensitivity and could be sustained with outstanding stability under the cyclic runs. The principle verification results demonstrated that the developed sensor could monitor the motion of a finger and serve as an electronic skin to display the distribution of pressure, suggesting its great potential for applications in wearable and flexible electronics.