str.replace replacement string variable name

NetEase cloud the classroom curriculum link address

https://study.163.com/course/courseMain.htm?share=2&shareId=400000000398149&courseId=1006383008&_trace_c_p_k2_=cd6d8636673a4b03b5f77ca55979c1a7

Python replace () method

description

Python replace () method of the string old (old string) replaced with new (new string), if the third argument max, max is not more than the replacement times.

grammar

replace () method syntax:

str.replace(old, new[, max])

parameter

  • old - substring to be replaced.
  • new - new string for replacing old substring.
  • max - optional string, alternatively no more than max times

return value

Returns string old (old string) replaced with a new string generated after the new (new string), if the third argument max, max is not more than the replacement times.

Examples

The following examples illustrate replace () function using the method:

Examples of the above output results are as follows:

thwas was string example....wow!!! thwas was really string
thwas was string example....wow!!! thwas is really string

 

eg

 

Micro-channel scan two-dimensional code, free resources to learn more python

 

Guess you like

Origin www.cnblogs.com/webRobot/p/11962224.html