Photo- and thermal-responsive polymers containing azobenzene units in the main chain have been utilized as removable dispersants for single-walled carbon nanotubes (SWNTs) in organic solvents. Intermolecular interactions between SWNTs and the polymers are reversibly controllable by tuning the trans-cis composition.