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