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