President Trump said he would be willing to listen to foreign governments if they approached him with information on a political rival.