python string replace character with space code example Example: python replace space with underscore mystring.replace(" ", "_")