string all spaces and replace with underscore python code example Example: space to underscore python mystring.replace(" ", "_")