감동, 마음이 움직이는 것

[python] replace characters in the string 본문

Tips (Utility, Computer Language, and etc.)

[python] replace characters in the string

Struggler J. 2017. 12. 21. 00:29

http://l4wisdom.com/python/python_string.php

replace()

str.replace(old, new, (optional) max) 

The replace() returns the string: after replacing the parameter old to new 

The parameter max defined how many occurrences have been replaced. If max is not specified then all occurrences will be replaced. 

[Example] 

newname = fname.replace("err", "out")