Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Example Analysis of replacement function in python

Shulou Source: shulou.com Published: 2022-05-31 11:15:29 10月18日 Update

Most people do not understand the knowledge points of this "python replacement function instance analysis" article, so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "python replacement function instance analysis" article.

Specific steps for use:

1. First open the python editor and create a new python project.

2. Define a string in the python project.

Str = "this is string example.wowning examples! this is really string"

3. Finally, replace the string through the replace () function.

Print str.replace ("is", "was")

Complete sample code:

#! / usr/bin/python

# www.xieniao.com

Str = "this is string example.wowning examples! this is really string"

Print str.replace ("is", "was")

Print str.replace ("is", "was", 3)

Output result:

Thwas was string example....wow!!! Thwas was really string

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

Expand knowledge:

Strip () # Delete the specified string function

Re.sub () # replaced by regular expression

The above is about the content of this article on "instance Analysis of substitution function in python". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Tags: Functions content examples case analysis analysis characters strings knowledge articles steps articles projects code values most that is more regularities knowledge points examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple MariaDB Docker MySQL